Skip to content

Commit

Permalink
Fix crash on FreeBSD due to incorrect thr_self system call invocation (
Browse files Browse the repository at this point in the history
…#285)

The correct signature is:
int thr_self(long *id);

It was called as thr_self() which caused memory corruption.
  • Loading branch information
yurivict authored Aug 16, 2024
1 parent 793f24c commit dcddfdd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libs/threading.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ INLINE void us_thread_get_name(char *name) { // Always required for logging
#if defined(__linux__)
const pid_t tid = syscall(SYS_gettid);
#elif defined(__FreeBSD__)
const pid_t tid = syscall(SYS_thr_self);
long id;
assert(!syscall(SYS_thr_self, &id));
const pid_t tid = id;
#elif defined(__OpenBSD__)
const pid_t tid = syscall(SYS_getthrid);
#elif defined(__NetBSD__)
Expand Down

0 comments on commit dcddfdd

Please sign in to comment.