Skip to content

Commit

Permalink
#Centipede Fix a leakage when the thread calls pthread_exit.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 578940654
  • Loading branch information
xinhaoyuan authored and copybara-github committed Nov 2, 2023
1 parent de4c3f0 commit 5b1b232
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions centipede/runner_interceptors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ struct ThreadCreateArgs {
// Performs custom actions before and after start_routine().
// `arg` is a `ThreadCreateArgs *` with the actual pthread_create() args.
void *MyThreadStart(void *arg) {
auto *args = static_cast<ThreadCreateArgs *>(arg);
auto *args_orig_ptr = static_cast<ThreadCreateArgs *>(arg);
auto args = *args_orig_ptr;
delete args_orig_ptr; // allocated in the pthread_create wrapper.
tls.OnThreadStart();
void *retval = args->start_routine(args->arg);
delete args; // allocated in the pthread_create wrapper.
void *retval = args.start_routine(args.arg);
return retval;
}

Expand Down

0 comments on commit 5b1b232

Please sign in to comment.