Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix usage of TerminateThread() causing critical section corruption. #2314

Merged
merged 1 commit into from
Nov 20, 2019

Commits on Nov 20, 2019

  1. Fix usage of TerminateThread() causing critical section corruption.

    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:
    > TerminateThread is a dangerous function that should only be used in
    > the most extreme cases. You should call TerminateThread only if you
    > know exactly what the target thread is doing, and you control all of
    > the code that the target thread could possibly be running at the time
    > of the termination.
    (https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-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.
    Jehan committed Nov 20, 2019
    Configuration menu
    Copy the full SHA
    1f60715 View commit details
    Browse the repository at this point in the history