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 corruption of thread linked list #8196

Merged
merged 1 commit into from Sep 18, 2019

Conversation

waj
Copy link
Member

@waj waj commented Sep 17, 2019

When a new thread finishes very quickly it could happen that the removal from the linked list was executed before the push. The linked list didn't check for that situation and it ends corrupted.

This is what was causing errors while the GC runs on the specs. There are some tests that create new threads with an almost empty body.

Fixes #8184

When a new thread finishes very quickly it could happen that
the removal from the linked list was executed before the push.
The linked list didn't check for that situation and it ends corrupted.
@bcardiff bcardiff merged commit a0132d5 into crystal-lang:master Sep 18, 2019
@bcardiff bcardiff added this to the 0.31.0 milestone Sep 18, 2019
@waj waj deleted the fix/thread-list-race-condition branch September 18, 2019 00:12
@asterite
Copy link
Member

A comment about this: it looks like a simple PR but it took days to find out the cause. The work these fixes take isn't related to the code change size at all!

dnamsons pushed a commit to dnamsons/crystal that referenced this pull request Jan 10, 2020
When a new thread finishes very quickly it could happen that
the removal from the linked list was executed before the push.
The linked list didn't check for that situation and it ends corrupted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GC.collect might not be thread-safe
3 participants