self icon indicating copy to clipboard operation
self copied to clipboard

NetBSD/i386 crashes in Spy

Open nbuwe opened this issue 1 year ago • 3 comments

"Toggle Spy" crashes on NetBSD/i386. I didn't look too closely, but from a superficial research I think the problem is that syscall stubs in libc do not save frame pointer. So the frame link that is expected to be at the saved_bp_offset is actually the return address and the stack walking code walks into the abyss.

nbuwe avatar Aug 16 '23 13:08 nbuwe

Ditto for FreeBSD

nbuwe avatar Aug 16 '23 23:08 nbuwe

On Linux we never seem to get non-null frame in ExecutionMonitor::current_tick_activity as we always seem to arrive there via interruptCheck.

On NetBSD we get there via the signal handler and IntervalTimerTick:

(gdb) bt
#0  ExecutionMonitor::current_tick_activity () at vm/src/any/runtime/selfMonitor.cpp:874
#1  0x080f226d in ExecutionMonitor::count_tick_and_return_log_char () at vm/src/any/runtime/selfMonitor.cpp:920
#2  0x080f120f in SelfMonitor::measure_current_tick_activity (this=0x841f000) at vm/src/any/runtime/selfMonitor.cpp:641
#3  0x080ee46f in SelfMonitor::tick_measure (this=0x841f000) at vm/src/any/runtime/selfMonitor.cpp:176
#4  0x080d8535 in Monitor::monitor_tick () at vm/src/any/runtime/monitor.cpp:136
#5  0x081ef8ad in TimerEntry::do_procs_if_needed (this=0x831d130) at vm/src/unix/os/itimer_unix.cpp:33
#6  0x08157634 in IntervalTimer::do_async_tasks (this=0x82f8060) at vm/src/unix/os/itimer_unix.cpp:272
#7  0x0815759f in IntervalTimerTick (sig=14, info=0x831bc78, scp=0x831bcf8) at vm/src/unix/os/itimer_unix.cpp:256
#8  <signal handler called>
#9  0xba3ca6d7 in recvmsg () from /usr/lib/libc.so.12
#10 0xba38fc6a in _xcb_in_read () from /usr/X11R7/lib/libxcb.so.2
#11 0xba3909dc in xcb_poll_for_event () from /usr/X11R7/lib/libxcb.so.2
[...]

In a slower debug build we are sometimes lucky to get there when the compiler is actually doing some work and the Spy briefly shows that SIC is compiling stuff, but then pretty quickly we hit a "weird" C statck that the unwinder cannot cope with.

nbuwe avatar Aug 18 '23 01:08 nbuwe

Ah, Linux just weasels out...

https://github.com/russellallen/self/blob/2889b618e36a8c8aa665e00bee908beac1166880/vm/src/unix/os/itimer_unix.cpp#L161-L163

Probably should do that for NetBSD and FreeBSD too for now.

Also probably needs to be restricted to i386.

nbuwe avatar Aug 18 '23 13:08 nbuwe