Debugging signal 11

Lucas Nali de Magalhães rollingbits at gmail.com
Sun Apr 18 18:53:42 UTC 2021


Hi.

There are a few problems after the end of your email. I inlined them.

> On Apr 16, 2021, at 8:51 PM, Johannes Totz <johannes at jo-t.de> wrote:
> My init(8) is crashing with a signal 11.

Crossing with the end, init is the mother of all processes. A longer
explanation is in the man page you cited, even. An explanation of signal 11
can be found by googling it and also in
https://www.cyberciti.biz/tips/segmentation-fault-on-linux-unix.html a text
I found googling. Short story: init is well tested, so it must be hardware fault.

> I've added a breakpoint() in kern_sig.c:
> 
> static int
> issignal(struct thread *td)
> {
>    // [snip]
> 
>    case (intptr_t)SIG_DFL:
>        /*
>         * Don't take default actions on system processes.
>         */
>        if (p->p_pid <= 1) {
> #ifdef DIAGNOSTIC
>            /*
>             * Are you sure you want to ignore SIGSEGV
>             * in init? XXX
>             */
>            printf("Process (pid %lu) got signal %d\n",
>                (u_long)p->p_pid, sig);
> 
>            breakpoint();    // added by me
> #endif
>            break;        /* == ignore */
>        }
> 
>    // [snip]
> }
> 
> That breaks to DDB where I can call dump. So far so good.

This also isn't the usual. Debugging a running process is possible but
the process you used is the wrong one. Debugging init, OTOH, is a
completely different story: init is the first process and is the most
important process of any unix. The actual command varies from
debugger to debugger but in gdb, "attach pid"  may do the trick for
you. You will need to be extra cautious because of you are aiming init.
Ideally, init is the process supposed to catch the signals and keep the
system running. So a break into it may cause your system to crash.

> But how do I get back to the stack(trace) and instruction that caused the segv? Either in DDB or KGDB?

"bt" is a shortcut for "backtrace" and is the command to get a stack trace
in gdb. BTW, "attach" and "bt" are two of the most basic debugger commands.

-- 
rollingbits — 📧 rollingbits at icloud.com 📧 rollingbits at gmail.com 📧 rollingbits at yahoo.com 📧 rollingbits at terra.com.br 📧 rollingbits at globo.com


More information about the freebsd-hackers mailing list