Heap problem

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Knows some wx things
Knows some wx things
Posts: 40
Joined: Mon Jun 09, 2008 9:59 pm

Heap problem

Post by philrosenberg » Tue Jan 29, 2019 11:42 am

I'm getting some sort of memory problem with the heap. I'm running a debug build of my software in the Visual Studio debugger and the following code sample

Code: Select all

wxString string="my string";
causes a debug assertion fail, with an error message saying

File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 996
Expression: __acrt_first_block == header

The error occurs when the wxScopedCharTypeBuffer<char> created by the call is deleted. From googling that error, it seems that a likely cause is that new is called in a dll and delete is called in a different dll or my exe. As all dlls and exes have different heaps the object is not there to delete.

I am kind of new to using dlls instead of static libs, if anybody can suggest where I could be going wrong that would be a huge help. Something that is kinda confusing to me is that the new and delete calls appear to be inlined in headers that get #included in my main application so I thought that they would actually be both created and destroyed on the heap of my exe.

I'm running with VS2017 and wxWidgets 3.0.4. This is a debug build and I'm linking against the Unicode debug (ud suffix) import libraries.

Part Of The Furniture
Part Of The Furniture
Posts: 3351
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Heap problem

Post by ONEEYEMAN » Wed Jan 30, 2019 5:32 pm

Did you build wx as static or DLL configuration?
Did you use any non-standard options when building?
Do you use any DLL in your software that you are linking to?
Are those DLL using the same type of linkage as the main .exe and wx?

And finally - did you buuilkd wx and your software with different compilers?

Thank you.

Post Reply