A new lecture: Crash N’ Burn

Tuxology team June 30th, 2008

We’ve just added a brand new tutorial to the lectures section on the site, entitled: “Crash and burn: Writing Linux application fault handlers“. Check out the full description, slides and example code on the lecture page.

Or, if you’d rather see our very own Gilad Ben-Yossef present the tutorial in front of a live audience, you’re welcome to attend one of the following venues:

Hope to see you there!

Tuxology team

2 Responses to “A new lecture: Crash N’ Burn”

  1. edwinon 19 Aug 2008 at 7:57 am

    Interesting lecture.
    There are some tiny additions I would make to libcrash:
    - use sigaltstack: if we get a fault because the stack was overrun, the fault handler can’t run w/o sigaltstack
    - use pthread_atfork() in libauto_crash and register a handler for those too, for example daemons usually do a fork() right on startup, currently LD_PRELOAD wouldn’t register a handler for the forked daemon
    - it would be nice if the fault handler could spawn a gdb and attach it to the (still running) faulting app. Perhaps print the PID and tell the user to attach gdb, and then go to sleep (using pselect or something) as an option
    - the signal_backtrace code for i386 and ppc looks dead, shouldn’t the first return be part of an #ifndef?
    return ret;
    #ifdef __i386__
    array[distance] = (void *)(context->uc_mcontext.gregs[REG_EIP]);
    #endif /* __i386__ */

    #ifdef __PPC__
    array[distance] = (void *)(context->uc_mcontext.regs->nip);
    #endif /* __PPC__ */

    return ret;

  2. Gilad Ben-Yossefon 20 Aug 2008 at 2:58 am

    Hi Edwin,

    Thanks for the feedback!

    About using an alternate signal stack, - you are of course right and I in fact considered doing this, unfortunately it makes the job of printing the back trace a lot more difficult. Specifically, we can no longer simply call backtrace().

    I have in my todo list to replace backtrace() with my code, both for platforms that don’t have frame pointer , such as the mips and for uCLibc based platforms that don’t have backtrace(). When/If I do that using an alternate sig stack certainly becomes an option.

    Regarding using pthread_atfork(), that’s a really nifty and simple idea which i haven’t thought about. Thanks :-)

    As for the the extra “return” at the end of the function, it’s a simple typo - I massaged the code to make it more simple and readable before publishing the lecture and this was simply left there by mistake.

    Many thanks for the valuable feedback,
    Gilad