Full Test Pass shows memory corruption at SLOWDRAWTEST
A Logo programming environment for Microsoft Windows
Brought to you by:
david_costanzo
For the past several releases, there has been some memory corruption when running the SLOWDRAWTEST. I investigated this once and tracked the corruption down to this line in SIMPLEREPORTTEST (testlib.lgo):
LOCALMAKE "lasterror ERROR
It was overwritten with this:
LOCALMAK\>€®\
How Reproducible:
Every Time
Steps to Reproduce:
1) Start FMSLogo.exe
2) Load src\test\testharness.lgo
3) Run through the test pass
What Happens:
When it comes time to run SLOWDRAWTEST.REDEFPTEST, there's a strange failure like:
I don't know how to ®
Expected Result:
The test pass runs to completion. Individual tests may have failed due to known bugs.
While porting FMSLogo to wxWidgets, I found that the debug version crashed every time that NETWORKTEST was run. Upon investigation, it looks like this was a race condition between NETACCEPTON/NETCONNECTON and NETWORKSHUTDOWN when asynchronous DNS was used. The problem is that the HOSTENT structure which NETACCEPTON/NETCONNECTON allocates gets freed in NETWORKSHUTDOWN. Although this calls WSACleanup, that is apparently not sufficient to stop any asynchronous calls in progress, which means that the call to WSAAsyncGetHostByName() might still attempt to write into the memory after it is freed. This results in random memory corruption, which, in the case cited in the bug description, manifests itself as corrupted definitions in the next test.
I have checked in a fix for this that uses a static buffer for HOSTENT, instead of dynamically allocated memory. This is an easy fix that side-steps the problem by simply not freeing the memory which WSAAsyncGetHostByName() might want to write into. It's not an ideal fix, though, since it adds 8K of static memory, even for sessions which don't use the networking API (which is nearly all sessions).
I have confirmed that this fix addresses the problem in the wxWidgets port and I was able to run the entire regression test suite to completion on Windows 95, something that I haven't been able to do since the network tests were added.
The fix will be available in FMSLogo 6.29.0.