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

clean up pending threads on fork #1181

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

clean up pending threads on fork #1181

wants to merge 10 commits into from

Conversation

TingDaoK
Copy link
Contributor

@TingDaoK TingDaoK commented Jan 22, 2025

Issue #, and/or reason for changes (REQUIRED):

  • When the process gets forked, the threads are NOT get copied.
  • But we have a lazy thread join method may copy the state of the threads that needs to be joined from the parent process.
  • So, when the child process tries to clean up the global state of the threads to be cleaned, it picks the threads info copied from parent process, and it's meaningless to the child process, which leads to a segfault.
  • https://man7.org/linux/man-pages/man2/fork.2.html

Description of changes:

TODO

  • This is likely not gonna solve all issues for fork but at least, it will solve the segfault we see
  • What will happen to windows?
  • we need to dive much deep into the fork, and how to deal with it with multiple background threads, just throw out ideas:
    • don't allow it?
    • call exec()?
    • join all threads?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@TingDaoK TingDaoK marked this pull request as ready for review January 23, 2025 23:17
@TingDaoK TingDaoK changed the title try to fix the fork crash clean up pending threads on fork Jan 23, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.

Project coverage is 84.11%. Comparing base (568f46b) to head (88ad60a).

Files with missing lines Patch % Lines
source/thread_shared.c 0.00% 7 Missing ⚠️
source/common.c 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1181      +/-   ##
==========================================
- Coverage   84.23%   84.11%   -0.12%     
==========================================
  Files          57       57              
  Lines        5980     5988       +8     
==========================================
  Hits         5037     5037              
- Misses        943      951       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants