Heap corruption in Windows 8 / 10 (SOLVED)

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Bothmann
Posts: 3
Joined: Mon, 2016-03-07, 10:56

Heap corruption in Windows 8 / 10 (SOLVED)

#1 Post by Bothmann »

We are currently using version 3.6.0 compiled with Visual Studio 2010 under Windows 7.

On some Windows 8 and Windows 10 machines we are experiencing strange heap corruption errors that cannot be reproduced with the debugger; running it in release mode from visual studio does not help either.
It does not happen on all Win8/10 machines, but I would say eight out of ten do crash with this heap corruption error.

By inserting some ::OutputDebugString methods i could trace down the problem to the DcmFileFormat::saveFile function.
I tried to step deeper into the dcmtk-code and adding more ::OutputDebugString methods, but somehow got lost.

If someone has similar problems and / or a solution I would appreciate it.

Code: Select all

	DcmFileFormat fileFormat;
	DcmDataset *dataset = fileFormat.getDataset();
	insertNonQueryData(dataset);
	dataset->putAndInsertString(DCM_AccessionNumber, "");

	DcmSequenceOfItems *scheduledProcedureSeq = new DcmSequenceOfItems(DCM_ScheduledProcedureStepSequence);
	DcmItem *item = new DcmItem();
	insertNonQueryDataIntoScheduledProcedureSequence(item);
	item->putAndInsertString(DCM_ScheduledStationAETitle, myAetitle.c_str());

	char temp[10];
	sprintf_s(temp, "%04d%02d%02d", date.wYear, date.wMonth, date.wDay);
	item->putAndInsertString(DCM_ScheduledProcedureStepStartDate, temp);
	scheduledProcedureSeq->append(item);
	dataset->insert(scheduledProcedureSeq);

	char filename[MAX_PATH];
	char filepath[MAX_PATH-100];
	GetTempPathA(MAX_PATH-100, filepath);
	if (GetTempFileNameA(filepath, "wlquery", 0, filename))
	{
		OFCondition status = fileFormat.saveFile(filename, EXS_LittleEndianExplicit, EET_UndefinedLength, EGL_withoutGL);
		std::stringstream dicomXML;
		dataset->writeXML(dicomXML);

		if (status.good())
		{
			return filename;
		}
		else
		{
			ERROROUT(9603, 0, status.text())
		}
	}
Last edited by Bothmann on Mon, 2016-03-21, 10:38, edited 1 time in total.

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Heap corruption in Windows 8 / 10

#2 Post by J. Riesmeier »

Did you already try the latest development snapshot? Maybe, the issue has been fixed with the following commit (problem with UID generation): http://git.dcmtk.org/?p=dcmtk.git;a=com ... 0f991ab2bf

Bothmann
Posts: 3
Joined: Mon, 2016-03-07, 10:56

Re: Heap corruption in Windows 8 / 10

#3 Post by Bothmann »

We are (unfortunately) using dcmppscu-3.6.0 and dcmstcom-3.6.0 as well which cannot be compiled with the latest dev-snapshot as some of the data header have been changed.
But I will try the patch you sent and report the outcome

Bothmann
Posts: 3
Joined: Mon, 2016-03-07, 10:56

Re: Heap corruption in Windows 8 / 10

#4 Post by Bothmann »

Good news, the patch you proposed did solve the problem. We tested it on 2 Win10 and 2 Win8 machines and did not get any heap corruption any more.
Thanks for the help!

J. Riesmeier
DCMTK Developer
Posts: 2504
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: Heap corruption in Windows 8 / 10 (SOLVED)

#5 Post by J. Riesmeier »

Thank you for the feedback!

I already closed the corresponding bug entry: http://support.dcmtk.org/redmine/issues/594#change-753

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest