rpmalloc icon indicating copy to clipboard operation
rpmalloc copied to clipboard

get_thread_id() implementation throws SIGILL on my ARM CPU

Open 12932 opened this issue 2 years ago • 1 comments

Hi, i've discovered that the implementation of get_thread_id() here https://github.com/mjansson/rpmalloc/blob/develop/rpmalloc/rpmalloc.c#L787-L818 doesn't appear to work on my hardware and I get SIGILL when using it:

# cat /proc/cpuinfo
Processor       : ARM926EJ-S rev 4 (v5l)
BogoMIPS        : 199.06
Features        : swp half thumb fastmult edsp java
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant     : 0x0
CPU part        : 0x926
CPU revision    : 4

Using this implementation from another piece of software I get the following error, caught by GDB:

Program received signal SIGILL, Illegal instruction.
0x000f232c in tracy::get_thread_id() ()
(gdb)

And the offending asm appears to be:

0xf232c <_ZN5tracyL13get_thread_idEv+12>                mrc    15, 0, r3, cr13, cr0, {3}

Is it possible the problematic assembly isn't supported on my version of ARM?

12932 avatar Feb 19 '24 12:02 12932

Could you try changing the implementation of get_thread_id to return (uintptr_t)__builtin_thread_pointer(); instead and see if that compiles and work for your platform/arch?

mjansson avatar May 12 '24 21:05 mjansson