mattgodbolt / xania

Xania MUD source
Other
58 stars 13 forks source link

xania crashes if gdb connects after it starts then tries to set a breakpoint #191

Closed mattgodbolt closed 4 years ago

mattgodbolt commented 4 years ago

Probably relates to the SIGINT that gdb needs to send to interrupt th eprocess to modify its address space.

mattgodbolt commented 4 years ago

I took a look at this: @snellers what did you see? I saw that if I ctrl-C in xania it shuts down (as expected), but gdb seemed to work ok.

Do you have a super minimal repro step? Like:

snellers commented 4 years ago

I don't debug xania that way now as I launch it in vscode. But if I do it the way you describe and hit ctrl-c in order to set a new breakpoint, sigint always kills the process instead of stopping it. Even if I use other tricks like running call sigignore(2) after starting gdb. This is with gdb 8.2.

And when running via a vscode debug target, it seems to be the same deal - the mud gets a shutdown signal as soon as you try to add a bp.

I also found an article talking about how if the process is using sigwait, that'll prevent gdb from intercepting the signal. The mud's not using that directly, but I'm wondering if it's due to how we use signalfd.

Anyway it's not a huge issue as the mud starts fairly quickly, it's not that hard to set breakpoints in advance.

snellers commented 4 years ago

Are you using gdb 9?

mattgodbolt commented 4 years ago

I am indeed using gdb 9.2.

I'll run in vscode and try to repro there :)

mattgodbolt commented 4 years ago

the SIGINT we trap and shut down normally (like c-C does). Previously I've configured gdb to use TSTOP or TRAP to stop a running process. I'm not sure what the right way to do this is.