ThinkGeo.com    |     Documentation    |     Premium Support

Hard Crash from UnmanagedProj4Projection

Hi,

I recently converted all my references from Proj4Projection to UnmanagedProj4Projection to support gdal projection methods; however, I now am having problems with hard crashes. Here’s the stack trace. Switching back to Proj4Projection prevents the crash.

System.Reflection.TargetInvocationException
HResult=0x80131604
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Dhg=.tlQ=.7U4=(Object[] objArray, Type[] typeArray, s1Q=[] modePassArray, Type returnType, IntPtr farProc)
at Dhg=.tlQ=.vkM=(IntPtr srcProjPtr, IntPtr dstProjPtr, Int32 pointCount, Int32 pointOffset, Double[] xArray, Double[] yArray, Double[] zArray)
at ThinkGeo.MapSuite.Shapes.UnmanagedProj4Projection.vkM=(IntPtr srcCs, IntPtr destCs, Int64 pointCount, Double[] x, Double[] y, Double[] z)
at ThinkGeo.MapSuite.Shapes.UnmanagedProj4Projection.ConvertToExternalProjectionCore(Double[] x, Double[] y)
at ThinkGeo.MapSuite.Shapes.Projection.8iQ=(Byte[] wellKnownBinary)
at ThinkGeo.MapSuite.Shapes.Projection.6yQ=(Byte[] wellKnownBinary)
at ThinkGeo.MapSuite.Shapes.Projection.ConvertToExternalProjection(Feature feature)
at lRc=.GRQ=.6yQ=(Projection projection, Feature feature)
at ThinkGeo.MapSuite.Layers.FeatureSource.ConvertToExternalProjection(IEnumerable1 features) at ThinkGeo.MapSuite.Layers.FeatureSource.sic=(Collection1 returnFeatures)
at ThinkGeo.MapSuite.Layers.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable1 returningColumnNames) at ThinkGeo.MapSuite.Layers.FeatureLayer.DrawCore(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.lic=(GeoCanvas canvas, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.Layers.Layer.Draw(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.WinForms.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.yFU=(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.WinformsMap.gVU=(IEnumerable1 drawingOverlays, RectangleShape extent) at ThinkGeo.MapSuite.WinForms.WinformsMap.gFU=(RectangleShape drawingExtent, RectangleShape extent) at ThinkGeo.MapSuite.WinForms.WinformsMap.n1U=(RectangleShape extent) at ThinkGeo.MapSuite.WinForms.WinformsMap.Refresh(RectangleShape extent, IEnumerable1 overlays)
at SurveyDesign.Map.HiResBinning() in C:\Users\damian\OneDrive - acteq.net\Visual Studio Projects\Projects\TesserACT\SurveyDesign\Map.cs:line 4840
at SurveyDesign.Map.WinformsMap1_CurrentExtentChanged(Object sender, CurrentExtentChangedWinformsMapEventArgs e) in C:\Users\damian\OneDrive - acteq.net\Visual Studio Projects\Projects\TesserACT\SurveyDesign\Map.cs:line 13260
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at ThinkGeo.MapSuite.WinForms.WinformsMap.OnCurrentExtentChanged(CurrentExtentChangedWinformsMapEventArgs e)
at ThinkGeo.MapSuite.WinForms.WinformsMap.eFU=(RectangleShape value, Double candidateScale)
at ThinkGeo.MapSuite.WinForms.WinformsMap.set_CurrentExtent(RectangleShape value)
at ThinkGeo.MapSuite.WinForms.WinformsMap.m1U=(InteractionArguments interactionArguments)
at ThinkGeo.MapSuite.WinForms.WinformsMap.jVU=(Object sender, vlU= e)
at ThinkGeo.MapSuite.WinForms.MouseEventAnalyzer.OnMouseEvent(vlU= e)
at ThinkGeo.MapSuite.WinForms.WinformsMap.mlU=(Object sender, MouseEventArgs e)
at System.Windows.Forms.Control.OnMouseWheel(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseWheel(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at TesserACT.Program.Main() in C:\Users\damian\OneDrive - acteq.net\Visual Studio Projects\Projects\TesserACT\TesserACT\Program.cs:line 19

This exception was originally thrown at this call stack:
.InvokeFunc(System.IntPtr, System.IntPtr, int, int, System.IntPtr, System.IntPtr, System.IntPtr)

Inner Exception 1:
AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Thanks,
Damian

Thanks Damian,
I still can not reproduce this issue. I created a demo project for you. Could you modify the project to reproduce this issue.

HelloWorldV10DESK.zip (1.9 MB)

If this is shape data related. Could you create a private ticket to upload the file or send it to support@thinkgeo.com

Thanks

Frank

Hi Frank,

I should mention that the error only occurs in Release mode or a compiled executable.

I’ll have a go at building your demo if that doesn’t reveal the issue for you.

Regards,
Damian

Thanks Damian,
In you release folder or the executable folder make sure you have the windows-X64/X86 folder there. The unmanaged proj dlls are in these folders. The visual studio should auto copy these two folders to the release/debug folder.

Thanks

Frank

Hi Frank,

Yes, the folders are there.

Regards,
Damian

Hi Frank,

I’ve modified your project to replicate the issue. I’ve also recorded a video, but I can’t attach it here. Here are some things to look at.

I’ve added an in memory feature layer with several thousand random colored points.

  1. Notice how long it takes for the project to load. It’s really slow.
  2. I zoom in tightly initially
  3. I am then zooming out with mouse wheel and the lag times between updates are increasing dramatically.
  4. Then the crash.

The issue did not show up until I assigned the projection to the imfl. If I leave this line out, the code functions well although if there was a transform needed to my project, I wouldn’t be able to do it…

UnmanagedCrash.zip (2.1 MB)

Regards,
Damian

Thanks Damian,
Yes. I can reproduce this issue. Two issues.

  1. The UnmanagedProj4Projection is real slow compare with the managedProj.
  2. Sometimes it will threw an error.

Because we are using gdal for the UnmanagedProj4Projection. It may take longer time to fix this issue. I would recommend switch back the managedProj. I remember you have one projection has to use the UnmanagedProj4Projection because the managedProj has some out of data projection. You many need check the proj string. Just use the UnmanagedProj4Projection for that specify projection.

Thanks

Frank