Re: mprotect, SIGBUS, and SIGSEGV
While working on getting the racket garbage collector working on
kFreeBSD, I (well, really upstream) noticed mprotect was sending
SIGBUS. Recently this changed so that it is sending SIGSEGV. I'm not
sure what exactly changed, except that catching SIGBUS works on squeeze
and catching SIGSEGV works on current sid. Upstream is happy to patch
for kFreeBSD support, but ideally I'd like to suggest something that
will build and work on both squeeze and sid/wheezy. Is there any static
way to detect this (some preprocessor symbol?), or do I need to run a
program at configure time?
What about catching both signals ?
The kernels sends SIGBUS/SIGSEGV according to declared program ABI,
which is in fact the lower supported kernel by eglibc.
$ file /bin/bash
/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD),
dynamically linked (uses shared libs), for GNU/kFreeBSD 6.0.0, stripped
$ file /srv/chroot/sid/lib/libc-2.13.so
ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD),
dynamically linked (uses shared libs), for GNU/kFreeBSD 8.0.0, stripped
$ file /srv/chroot/squeeze/lib/libc-2.11.2.so
ELF 64-bit LSB shared object, x86-64, version 1 (FreeBSD),
dynamically linked (uses shared libs), for GNU/kFreeBSD 6.0.0, stripped
The squeeze eglibc needs at least 6.0 kernel
and the sid one needs at least 8.0 kernel.
Is there any static
way to detect this (some preprocessor symbol?), or do I need to run a
program at configure time?
There is no way, signal is determined by eglibc compiled for.
Lets assume that your binary is compiled under squeeze.
Under squeeze eglibc, it will receive SIGBUS,
under sid eglibc it will receive SIGSEGV.
Catching both signals is the easiest approach.
Petr
Reply to: