[asterisk-dev] [patch] Fix trunk build on NetBSD

Rafal Boni rafal at pobox.com
Mon Dec 10 22:33:01 CST 2007


Attached is a patch I needed to get the trunk to build on NetBSD.

I was grabbing the trunk since 1.4.15 still had trouble starting up on
NetBSD due to mutex-initialization issues (I had to resort to some gross
hacks to get out of the "static initialization order fiasco" [1] and
then it ran) and I was hoping trunk would do better.

The good news is that the trunk does indeed appear to deal with
threading and mutex issues better on NetBSD, the bad news is that it
crashes in a multitude of what looks to be unrelated ways:

    (1) Error parsing the 'for' loop construct in the sample
	extensions.ael ('for (x=0; ${x} < 3; x=${x} + 1) {').
	It looks like the '${x} < 3' expression causes the
	first arg of the comparison to end up as the actual
	ASCII data rather than a pointer to it. Boom!

    (2) If I comment out the for loop, asterisk starts up OK,
	but the 1st SIP call kills it with a bus error.  Note
	that I'm running on a sparc64 and building in native
	64-bit mode; I suspect this is related to attempting
	to deref non-byte data directly out of a packed buffer.

Core was generated by `asterisk'.
Program terminated with signal 10, Bus error.
#0  0x000000000015fc34 in ast_event_get_ie_uint (event=0x41707d00,
    ie_type=AST_EVENT_IE_STATE) at event.c:419
419             return ie_val ? ntohl(*ie_val) : 0;
(gdb) where
#0  0x000000000015fc34 in ast_event_get_ie_uint (event=0x41707d00,
    ie_type=AST_EVENT_IE_STATE) at event.c:419
#1  0x000000004cc09fdc in device_state_cb (event=0x41707d00, unused=0x0)
    at app_queue.c:769
#2  0x0000000000160974 in ast_event_dispatcher (unused=0x0) at event.c:789
#3  0x00000000001d0fe8 in dummy_start (data=0x41608aa0) at utils.c:857
#4  0x0000000040f0b978 in pthread_create () from /usr/lib/libpthread.so.0
#5  0x00000000411b07a0 in _lwp_makecontext () from /lib/libc.so.12
#6  0x00000000411b07a0 in _lwp_makecontext () from /lib/libc.so.12
Previous frame identical to this frame (corrupt stack?)
(gdb) x/i $pc
0x15fc34 <ast_event_get_ie_uint+116>:   ld  [ %g4 ], %g1
(gdb) p/x $g4
$2 = 0x41707d1d
(gdb)

Anyway, the patch to get it to build is a start :)

On a related note, is there something inbetween the wild-west of the
trunk and the release branches I can try out?  Or should I just duke it
out with the trunk and see how far I get?  Honestly, I think putting the
ugly hacks into 1.4.15 seems like less of a slog at this point ;)

--rafal

[1] http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12
    The same applies to the .ctors used to initialize mutexes
    on BSD and SOLARIS... for example by 1.4.15 asterisk binary
    would fall over 99.99% of the time due to the file_versions
    list mutex not being initialized before the list was used by
    another ctor.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ast-svn-build.diff
Url: http://lists.digium.com/pipermail/asterisk-dev/attachments/20071210/fdde74e0/attachment.txt 


More information about the asterisk-dev mailing list