Professional Documents
Culture Documents
1
OR
Gilad Ben-Yossef
Chief Coffee Drinker
Codefidence Ltd.
gilad@codefidence.com
http://codefidence.com 1
What's this tutorial is about?
Segmentation fault:
core dumped
2
Dealing with faults
3
What's wrong with core dumps?
● Instant gratification
● No space left on device for 753Mb core
dump
● No source, no (network) access but
working code needed for paycheck
● Access to external state (e.g. FPGA)
● Easier access to internal state machine.
● Custom fault behavior
● Haiku error messages
4
Haiku error messages?
6
Signals
● Signals are asynchronous notifications
sent to a process by the kernel,
another process or itself
● Process can register a signal handler
function to respond to signal
● Process faults make the kernel
generate a signal
● ... which the process can catch and
respond to
Signals Worth Catching
• SIGQUIT - Quit from keyboard
• SIGILL - Illegal Instruction
... ...
Handler returns
Signal trampoline
handling
code
Kernel in vsyscall
page
Putting It All Together
● Fork a “watchdog” process sleeping on
a pipe to handle faults
– System wide daemon also possible
● Collect information in signal handler and
send it over the pipe to the watchdog
process for analysis, printing etc.
● Finalize by sending
backtrace_symbols_fd down the pipe
● Use EIP from signal context to
overcome stack munging
Questions?
Gilad Ben-Yossef
Chief Coffee Drinker
Codefidence Ltd.
gilad@codefidence.com
http://codefidence.com
© 2008 Codefidence Ltd.
Released under a CC-by-sa 2.5 License.
25