tracy
tracy copied to clipboard
Program received signal SIGILL, Illegal instruction. 0x000f232c in tracy::get_thread_id() ()
I'm trying to get Tracy targeting an embedded linux target, after building successfully and deploying my binary and running it, I get a SIGILL error. Running with GDB I get the following:
(gdb) run
Starting program: /root/a
warning: File "/lib/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /lib/libthread_db-1.0.so
line to your configuration file "/root/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/root/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Program received signal SIGILL, Illegal instruction.
0x000f232c in tracy::get_thread_id() ()
(gdb)
Showing the assembly, it's this instruction that appears to be problematic:
0xf232c <_ZN5tracyL13get_thread_idEv+12> mrc 15, 0, r3, cr13, cr0, {3}
▒0xf2320 <_ZN5tracyL13get_thread_idEv> push {r11} ; (str r11, [sp, #-4]!) ▒
▒0xf2324 <_ZN5tracyL13get_thread_idEv+4> add r11, sp, #0 ▒
▒0xf2328 <_ZN5tracyL13get_thread_idEv+8> sub sp, sp, #12 ▒
>▒0xf232c <_ZN5tracyL13get_thread_idEv+12> mrc 15, 0, r3, cr13, cr0, {3} ▒
▒0xf2330 <_ZN5tracyL13get_thread_idEv+16> str r3, [r11, #-8] ▒
▒0xf2334 <_ZN5tracyL13get_thread_idEv+20> ldr r3, [r11, #-8] ▒
▒0xf2338 <_ZN5tracyL13get_thread_idEv+24> mov r0, r3 ▒
▒0xf233c <_ZN5tracyL13get_thread_idEv+28> sub sp, r11, #0 ▒
▒0xf2340 <_ZN5tracyL13get_thread_idEv+32> pop {r11} ; (ldr r11, [sp], #4) ▒
▒0xf2344 <_ZN5tracyL13get_thread_idEv+36> bx lr ▒
▒0xf2348 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE> push {r11, lr} ▒
▒0xf234c <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+4> add r11, sp, #4 ▒
▒0xf2350 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+8> sub sp, sp, #8 ▒
▒0xf2354 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+12> str r0, [r11, #-8] ▒
▒0xf2358 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+16> ldr r3, [pc, #56] ; 0xf2398 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+80> ▒
▒0xf235c <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+20> ldr r3, [pc, r3] ▒
▒0xf2360 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+24> bl 0xe3c900 <__aeabi_read_tp> ▒
▒0xf2364 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+28> mov r1, r0 ▒
▒0xf2368 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+32> ldr r2, [r11, #-8] ▒
▒0xf236c <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+36> str r2, [r1, r3] ▒
▒0xf2370 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+40> ldr r3, [r11, #-8] ▒
▒0xf2374 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+44> cmp r3, #0 ▒
▒0xf2378 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+48> beq 0xf238c <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+68> ▒
▒0xf237c <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+52> bl 0xf2320 <_ZN5tracyL13get_thread_idEv> ▒
▒0xf2380 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+56> mov r2, r0 ▒
▒0xf2384 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+60> ldr r3, [r11, #-8] ▒
▒0xf2388 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+64> str r2, [r3] ▒
▒0xf238c <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+68> nop ; (mov r0, r0) ▒
▒0xf2390 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+72> sub sp, r11, #4 ▒
▒0xf2394 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+76> pop {r11, pc} ▒
▒0xf2398 <_ZN5tracyL15set_thread_heapEPNS_6heap_tE+80> rscseq r12, lr, r4, lsl #7 ▒
▒0xf239c <_ZN5tracy24rpmalloc_set_main_threadEv> push {r11, lr} ▒
▒0xf23a0 <_ZN5tracy24rpmalloc_set_main_threadEv+4> add r11, sp, #4 ▒
▒0xf23a4 <_ZN5tracy24rpmalloc_set_main_threadEv+8> bl 0xf2320 <_ZN5tracyL13get_thread_idEv> ▒
▒0xf23a8 <_ZN5tracy24rpmalloc_set_main_threadEv+12> mov r2, r0 ▒
▒0xf23ac <_ZN5tracy24rpmalloc_set_main_threadEv+16> ldr r3, [pc, #8] ; 0xf23bc <_ZN5tracy24rpmalloc_set_main_threadEv+32> ▒
▒0xf23b0 <_ZN5tracy24rpmalloc_set_main_threadEv+20> str r2, [r3] ▒
▒0xf23b4 <_ZN5tracy24rpmalloc_set_main_threadEv+24> nop ; (mov r0, r0) ▒
▒0xf23b8 <_ZN5tracy24rpmalloc_set_main_threadEv+28> pop {r11, pc}
I'm not sure exactly why it's an illegal instruction, i'm no expert in ARM assembly. My target platform has the following:
# 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
Is it possible the problematic assembly isn't supported on my version of ARM?
Access to some of the registers through the mrc
/mrs
instruction may be restricted to kernel space, depending on the kernel configuration. See 5fbb811f5d for an example of how this was handled by Tracy some time ago in code that has since been removed.
This is an issue in https://github.com/mjansson/rpmalloc, as seen in https://github.com/mjansson/rpmalloc/blob/b41aa177fc56d1d3d0c61531cd1719f38fc20d5d/rpmalloc/rpmalloc.c#L787-L818
Please create an issue for rpmalloc. It doesn't seem necessary to resort to assembly hacks to get a thread id (usually a gettid()
call). At least a compatible fallback should be available, in my opinion.