Skip to content

Commit

Permalink
Only try to profile threads in valid samplers. (#4672)
Browse files Browse the repository at this point in the history
This adds a check to ensure we're not sending profiling signals to
threads in invalid samplers.

b/388595578
  • Loading branch information
jellefoks authored Jan 9, 2025
1 parent 8616801 commit ca2b1f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions starboard/shared/pthread/thread_sampler_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ SbThreadContext SignalHandler::Freeze(SbThreadSampler sampler) {
if (!signal_handler_installed_ || SbThreadSamplerIsValid(frozen_sampler_)) {
return kSbThreadContextInvalid;
}
frozen_sampler_ = sampler;
pthread_kill(SB_PTHREAD_INTERNAL_THREAD(sampler->thread()), SIGPROF);
sem_wait(&freeze_semaphore_);
if (SbThreadSamplerIsValid(sampler)) {
frozen_sampler_ = sampler;
pthread_kill(SB_PTHREAD_INTERNAL_THREAD(sampler->thread()), SIGPROF);
sem_wait(&freeze_semaphore_);
}
return &sb_context_;
}

Expand Down

0 comments on commit ca2b1f5

Please sign in to comment.