Page 1 of 1

Image::write crashing with release (but not debug) DLLs

Posted: 2010-04-27T11:08:06-07:00
by GSosebee
Hi, all.

I'm just getting started with IM and I wrote a little code to split a TIFF into multiple PNGs. I started with Visual Studio 2008 MFC App Wizard and generated a dialog-based application, then just dropped the following code into the OnInitDialog method.

std::list<Magick::Image> imgList;
std::list<Magick::Image>::iterator i;
char chName[MAX_PATH];

Magick::readImages(&imgList,"c:\\temp\\multipage_tiffs\\diary.tif");
if (!imgList.empty())
{
int nCnt;
for(nCnt = 0, i = imgList.begin();i != imgList.end(); i++, nCnt++)
{
_stprintf_s(chName,sizeof(chName),"c:\\temp\\im%02d.png",nCnt);
i->write(chName);
}
}

When I link with the release version of the DLLs (v 6.6.1-5), the program crashes on the "i->write" statement:
"Unhandled exception at 0x7855ae7a (msvcr90.dll) in TestImageMagick.exe: 0xc000000d: Access violation reading location 0xcccccccc."

When running with the debug version of the DLLs, it works just fine.

Any help would be appreciated.

Re: Image::write crashing with release (but not debug) DLLs

Posted: 2010-04-28T10:22:09-07:00
by GSosebee
A followup: the problem does not happen using the RELEASE version of my program and the RELEASE version of the DLLs. In other words, it's a compatibility issue caused by the compiler (I guess) that has to do with argument passing. When I step through the debug-compiled program into the non-debug-compiled DLLs, the string reference argument to Image::write is screwed up.

I'd say chalk this one up to Microsoft.