Fix usage of TerminateThread() causing critical section corruption. #2314
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So here is the deal: we have crashes in GIMP on Windows where a specific security software is used. We got in touch with the publisher (through a user of both GIMP and this software) and they told us the problem does not come from GIMP, but from OpenBlas (which is an indirect dependency of GIMP through SuiteSparse) with the technical explanation which I gave in the commit message.
They also told us a similar problem was discussed here: https://stackoverflow.com/questions/39635817/windows-10-specific-crash-on-call-leavecriticalsection
So for some reason, they don't want to discuss this publicly or whatever, which is why I am doing the intermediary and why I don't even cite their name or the software's name, which is stupid — I know — as contributing to Free Software is to their credit. But whatever apparently they want to keep their contribution quiet.
This patch was submitted to the GIMP project by a publisher wishing to
keep confidentiality (hence anonymously). I just pass along the patch.
Here is the patch explanation which came with:
First they remind us what Microsoft documentation says about
TerminateThread:
Then they say that 5 milliseconds time-out might not be long enough for
the thread to exit gracefully. They propose to set it to a much higher
value (for instance here 5 seconds).
And finally you should always check the return value of
WaitForSingleObject(). In particular you want to run TerminateThread()
only if WaitForSingleObject() failed, not on success case.