From 89d6959adbc09a86c0b3618b84ac4f37f7d4bcdc Mon Sep 17 00:00:00 2001 From: Raphael Theiler Date: Sun, 21 Jun 2026 22:13:58 +0200 Subject: [PATCH] Running the program in console mode and with xml output enabled, sometimes leads to a SegFault. It appears that ExitProgram tries to close a channel that's already closed. After closing and releasing the channel i reopened the Channel 1 again, that seems to fix the issue. --- DFUnit/AppSrc/DFUnit/Reporting/Reporters/XMLReporter.pkg | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DFUnit/AppSrc/DFUnit/Reporting/Reporters/XMLReporter.pkg b/DFUnit/AppSrc/DFUnit/Reporting/Reporters/XMLReporter.pkg index 303b3ab..97bc83d 100644 --- a/DFUnit/AppSrc/DFUnit/Reporting/Reporters/XMLReporter.pkg +++ b/DFUnit/AppSrc/DFUnit/Reporting/Reporters/XMLReporter.pkg @@ -63,7 +63,7 @@ Class cDFUnitXMLReporter is a cDFUnitResultCollector_Mixin Move (SizeOfArray(oTestResult.aFailedAssertions) - 1) to iMaxIndex For iIterator from 0 to iMaxIndex - Move (oTestResult.aFailedAssertions[iMaxIndex].sAssertMessage + XML_NEWLINE_REPLACE) to sMessage + Move (oTestResult.aFailedAssertions[iIterator].sAssertMessage + XML_NEWLINE_REPLACE) to sMessage Move oTestResult.aFailedAssertions[iIterator].asMessages to asMessages Move (SizeOfArray(asMessages) - 1) to iMaxMessageIndex @@ -129,6 +129,12 @@ Class cDFUnitXMLReporter is a cDFUnitResultCollector_Mixin Send Write '' Close_Output channel iChannel + Send Seq_Release_Channel iChannel + // Restore the current output channel to the default (channel 1). After + // Close_Output the global "current output channel" still points at the + // channel we just released; when a console run exits via ExitProcess the + // runtime dereferences that dangling pointer and intermittently crashes. + Append_Output Channel 1 Set piChannel to -1 End_Procedure