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

[2018-02] [threads] Fix race between abort socket syscall and thread shutdown #7521

Merged
merged 2 commits into from Mar 9, 2018

Conversation

monojenkins
Copy link
Contributor

Backport of #7507.

/cc @lambdageek

The race happens when we call mono_thread_info_abort_socket_sycall_for_close on
a thread that's about to shut down.

We lookup the MonoThreadInfo for that thread outside the
mono_thread_info_suspend_lock, and then use it to send the signal once we've
taken the lock.

In between those two actions, the other thread already finished
unregister_thread and pthreads may already have destroyed its TLS keys and
otherwise started to dismantle the thread.

The fix is to do a second mono_thread_info_lookup once we have the lock and
only signal the other thread if it still around.

Fixes mono#6998
Call mono_thread_info_lookup while holding the thread info suspend lock.
We no longer need to check for STATE_DETACHED because removing MonoThreadInfo on
detach is done while holding the suspend lock.
@monojenkins monojenkins added this to the 2018-02 (5.12.xx) milestone Mar 9, 2018
@lambdageek
Copy link
Member

@monojenkins build failed

@luhenry luhenry self-assigned this Mar 9, 2018
@luhenry luhenry merged commit 279d7e2 into mono:2018-02 Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants