[Gc] Re: Boehm GC on FreeBSD trouble, and maybe fix?

Dimitry Andric dim at FreeBSD.org
Sat Feb 12 05:53:14 PST 2011


On 2011-02-03 23:03, Ivan Maidanski wrote:
> 1. I've already fixed the issue (but in a different way), see http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/bdwgc-7_2alpha5-20110107.tar.bz2
> The mine variant is:
>
> #   if defined(FREEBSD)
> #     define SIG_OK TRUE
> #     define CODE_OK (si ->  si_code == BUS_PAGE_FAULT \
>                        || si ->  si_code == 2 /* experimentally determined */)

Ah yes, at the time I mailed you, I tried to access the bwdgc CVS
repository to review the latest version of this code, but SourceForge
had just disabled all their CVS service, due to a security breach. :(

I guess the only 'improvement' to be made here is to use:

#     define SIG_OK (sig == SIGBUS || sig == SIGSEGV)

since any other signal should not occur here.


> 2. Probably, it's better to use SEGV_ACCERR instead of 2 but I couldn't find it at least in FreeBSD r6.2.

That is correct, I should have checked old versions too.  The
SEGV_ACCERR define was introduced in FreeBSD 7.0.


> 3. Have you tested your code with some older FreeBSD releases (it can't test it right now but it seems that the old code worked before FreeBSD r7).

Actually, your solution is probably the most dependable one. :)

In FreeBSD 6.x and earlier, for a page fault due to invalid permissions,
the system generated SIGBUS, with the si_code field set to
BUS_PAGE_FAULT (=12).

In FreeBSD 7.0 and later, the system generates SIGSEGV, with the si_code
field set to SEGV_ACCERR (=2).

Actually, there is a compatibility sysctl that lets you switch between
the 'old' SIGBUS+BUS_PAGE_FAULT mode, and the 'new' SIGSEGV+SEGV_ACCERR
mode.  The default setting of this sysctl even autodetects whether a
pre-7.0 executable is running, in which case it generates SIGBUS.  For
post-7.0 executables, it generates SIGSEGV.


More information about the Gc mailing list