I’ve just updated to Windows XP64, and I’ve noticed that compiling my old project that uses JUCE146 with VS2003 leads to Heap Corruptions upon execution. It seems like the fact that the OS is 64Bit somehow breaks something in the compiler’s process. The problem really happens during the build, because when I compile the app on a 32Bit XP system and then let it run on XP64, then everything’s fine. Does anyone know what possible reasons can lead to such problems? I really don’t know where to start looking at.
[EDIT: The problem was actually the fact that the system had a multiprocessor, which made the multithreading-related bug in my app happen more often, not the XP64/VS2003 combo as previously stated.]
Run the Debug version of your application, and turn on MSVC debug heap checking. Make sure you are linking with the Debug runtimes.
Here is some magic code that you should add in your app initialization:
#include <crtdbg.h>
int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
// check leaks at exit
flag |= _CRTDBG_LEAK_CHECK_DF;
// check heap at every heap call
flag|= _CRTDBG_CHECK_ALWAYS_DF; // on
//flag&=~_CRTDBG_CHECK_ALWAYS_DF; // off
flag = _CrtSetDbgFlag( flag );
Shortly after your heap gets corrupted, you should get a breakpoint, and this will help you narrow down the place.
Now Juce has some conflicts with the MSVC debug heap interfaces (crtdbg.h) due to macros, so you will need to wrap the place where you include juce.h include like this:
Ah, that bit of code’s really old - I haven’t used a malloc for a long long time now. Best to stick to the latest version if you’re doing 64-bit stuff.
Jules, I found 2 other recurring “problems” in JUCE (in the tip) using BoundsChecker. I don’t know if they are important (if they can lead to other problems). But I’m just reporting them.
Problem 1 (in FontDCHolder::loadFont()) :
if (dc != 0)
{
DeleteDC (dc); // <----------- Argument 1 in DeleteDC (HDC__ hdc = 0xE1010FEE) still contains non default/stock objects. Font (0x7E0A1034).
DeleteObject (fontH);
kps.free();
}
DeleteDC Contains Selected Objects
Description
It is improper to DeleteDC a DeviceContext that still contains non-default objects.
Thanks! I don’t think those actually matter - it’s been running happily like that for years without any problems or leaks, but I’ll take a look and see if I can avoid the warnings!