Search This Blog

Thursday, June 27, 2013

_CrtIsValidHeapPointer(pUserData) assertion when compiling with /clr

The following explains how to resolve this issue when we are using unmanged code with managed one. Especially when we got an error in _CrtIsValidHeapPointer(pUserData), we can solve this issue by putting '__DllMainCRTStartup@12' in Force Symbol Reference in the Linker section/Input.

"I had a very similar problem with one of my mixed (managed and unmanaged) projects. I was using a Winforms with /clr specified for the GUI side calling into unmanaged code that at some point referenced a ATL header. Supposedly the winforms wizard configures the project by default to skip the CRT startup code when any ATL header file is detected and thus the reason for it crashing at the g_allocator initialization (this problem is not in the console /clr version). The fix below essentially reverses what the wizard does. On a side note, I included instructions below to obtain access to MSFTs symbols for use when debugging which helped me find this one, atleast to the point I knew what to search for in Google.

Link describing the problem
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715&wa=wsignin1.0

Anyhow here was what I had to do: add  __DllMainCRTStartup@12 in Force Symbols Reference section in the Linker section of the project settings.


VS2008 - To configure Symbol Server, open the symbol search path options dialog. (From the Tools menu, click Options. In the left pane of the Options dialog box, Open the Debugging node and click Symbols.) Add the following search path to the search list: http://msdl.microsoft.com/download/symbols. Add a symbol cache directory to the symbol server cache text box. Click OK."

Ref. http://social.msdn.microsoft.com/Forums/vstudio/en-US/62db4002-4ebc-4a3a-91ec-9fc702db821e/crtisvalidheappointerpuserdata-why-is-this-code-broken-vs2008

No comments:

Post a Comment

Blog Archive