Skip to content

Commit

Permalink
Fix wrong integer width for native_thread_id on macOS on Ruby 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoanjo committed Apr 6, 2024
1 parent e638b07 commit 205ff41
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/gvl_tracing_native_extension/gvl_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ static inline void initialize_thread_local_state(thread_local_state *state) {
uint32_t native_thread_id = 0;

#ifdef HAVE_PTHREAD_THREADID_NP
pthread_threadid_np(pthread_self(), &native_thread_id);
uint64_t full_native_thread_id;
pthread_threadid_np(pthread_self(), &full_native_thread_id);
// Note: `pthread_threadid_np` is declared as taking in a `uint64_t` but I don't think macOS uses such really
// high thread ids, and anyway perfetto doesn't like full 64-bit ids for threads so let's go with a simplification
// for now.
native_thread_id = (uint32_t) full_native_thread_id;
#elif HAVE_GETTID
native_thread_id = gettid();
#else
Expand Down

0 comments on commit 205ff41

Please sign in to comment.