dasl- / pifi

10 stars 1 forks source link

snake segfault #39

Open dasl- opened 1 year ago

dasl- commented 1 year ago

This appears to be a rarely occuring issue. I've only encountered it once.

Just playing a friendly 2 player game of snake. We had eaten 14 out of 15 apples. Suddenly a segfault and the game freezes:

% sudo strace -p 30063
strace: Process 30063 attached
sigreturn({mask=[]})                    = 2
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1} ---
sigreturn({mask=[]})                    = 2
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x1} ---
sigreturn({mask=[]})
... etc ...

Nothing useful in logs.

Install python3 debug symbols: sudo apt-get install python3-dbg

gdb backtrace: https://gist.github.com/dasl-/03c2571ff1f12d3500b3bc90ee5c597a

This appears to be different than the segfault we encountered in https://github.com/dasl-/pifi/issues/26. Here it looks like the segfault occurs on this line: https://github.com/dasl-/pifi/blob/39760cad6447d2e3514f1fe8d9b6f2f690658d2b/bin/snake#L57

And it looks like the exception that was caught was: TypeError("'range_iterator' object is not subscriptable",). I am confused for a couple reasons:

1) Why is catching an exception and printing the traceback causing a segfault? 2) What is causing this TypeError to be thrown in the first place?

jordanlewis commented 1 year ago

How did you catch the process output via strace if you were in the middle of the game? Is it reproducible?

dasl- commented 1 year ago

Sup. The process just hung and permanently pegged a CPU at 100% when the segfault occurred. So it didn't kill the process, it was just hung and unresponsive. Not reproducible :[

So I was able to attach strace and gdb while it was hung.