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 BUG(Issue #1776): Switching pthread causes coredump when bthread local variable is destructed #1777

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/bthread/task_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ void TaskGroup::task_runner(intptr_t skip_remained) {
thread_return = e.value();
}

// Group is probably changed
g = tls_task_group;

// TODO: Save thread_return
(void)thread_return;

Expand All @@ -314,13 +311,16 @@ void TaskGroup::task_runner(intptr_t skip_remained) {
// Clean tls variables, must be done before changing version_butex
// otherwise another thread just joined this thread may not see side
// effects of destructing tls variables.
KeyTable* kt = tls_bls.keytable;
KeyTable* kt = m->local_storage.keytable;
if (kt != NULL) {
return_keytable(m->attr.keytable_pool, kt);
// After deletion: tls may be set during deletion.
tls_bls.keytable = NULL;
m->local_storage.keytable = NULL; // optional
}

// Group is probably changed
g = tls_task_group;

// Increase the version and wake up all joiners, if resulting version
// is 0, change it to 1 to make bthread_t never be 0. Any access
Expand Down