Perhaps alarm() is not thread-safe in your C library?

The only thing that alarm() does is suspend alarms while it is in heap management code (such as malloc() which is called by fs_get()). It's basically a mutex around alarms. This is because the busy spinner in Pine runs in an alarm handler and writes to stdout, which is bad practice in any case and particularly bad juju with some C libraries where it led to all sorts of wierd crashes.

I think that Alpine does its busy spinner in a thread (which would have proper mutexes), so you may be able to remove the alarm() calls entirely in mm_blocknotify() in file env_unix.c. It looks like you can remove the entire code of that routine and just make it return null.

On Tue, 17 Feb 2009, Matthew McAughan wrote:
Have an Asterisk PBX (phone system) that stores the voice mail in IMAP with
libc-client. Concurrent access to voicemail, not the same mail box is
crashing the system. Any ideas what might cause a back trace like this?
Notice there are always to threads involved when there is a segfault but
cannot piece together why. Thanks! (sorry if this is posted twice sent
original before subscription confirmation)

Thread 8 (process 4920):
#0  0x00ffb402 in __kernel_vsyscall ()
#1  0x008e27c2 in alarm () from /lib/libc.so.6
#2  0x0169528b in mm_blocknotify (reason=1, data=0x0) at env_unix.c:1631
#3  0x0168c0f1 in fs_get (size=32) at fs_unix.c:29
#4  0x0169d0e3 in mail_newaddr () at mail.c:5327
#5  0x016c31f2 in imap_parse_address (stream=0x9db3190, txtptr=0x1856b30,
reply=0x9db9484) at imap4r1.c:4543
#6  0x016c3596 in imap_parse_adrlist (stream=0x9db3190, txtptr=0x1856b30,
reply=0x9db9484) at imap4r1.c:4499
#7  0x016c370f in imap_parse_envelope (stream=0x9db3190, env=0xac17b7dc,
txtptr=0x1856b30, reply=0x9db9484) at imap4r1.c:4440
#8  0x016c5430 in imap_parse_unsolicited (stream=0x9db3190, reply=0x9db9484)
at imap4r1.c:3651
#9  0x016c71cd in imap_reply (stream=0x9db3190, tag=0x1857076 "000019b8") at
imap4r1.c:3453
#10 0x016c7248 in imap_sout (stream=0x9db3190, tag=0x1857076 "000019b8",
   base=0x9db94d8 "000019b8 FETCH 2 (UID ENVELOPE BODY.PEEK[HEADER.FIELDS
(Newsgroups Content-Location Followup-To References)] INTERNALDATE
RFC822.SIZE FLAGS)\r\n", s=0x1857088) at imap4r1.c:3411
#11 0x016c8c5c in imap_send (stream=0x9db3190, cmd=0x1739ad7 "FETCH",
args=0x18570c8) at imap4r1.c:3045
#12 0x016c901c in imap_fetch (stream=0x9db3190, sequence=0xac00ee88 "2",
flags=<value optimized out>) at imap4r1.c:5427
#13 0x016cae08 in imap_search (stream=0x9db3190, charset=0x0,
pgm=0xac530978, flags=<value optimized out>) at imap4r1.c:2076
#14 0x0169ddb3 in mail_search_full (stream=0x9db3190, charset=0x0,
pgm=0xac530978, flags=<value optimized out>) at mail.c:2237
#15 0x0634ebb5 in messagecount (context=0x18577b5 "druid-default",
mailbox=0x18577b0 "5039", folder=0x635f0db "INBOX") at app_voicemail.c:1232
#16 0x0634f64b in inboxcount (mailbox_context=0x185a850 "5...@druid-default",
newmsgs=0x185d8a4, oldmsgs=0x185d8a0) at app_voicemail.c:1385
#17 0x0635567b in notify_new_message (chan=0xac433a28, vmu=0x1867ee0,
msgnum=1, duration=6,
   fmt=0x1858850
"/var/spool/asterisk/voicemail/druid-default/5039/INBOX/msg0001.txt",
cidnum=0xabc5db40 "7134809419",
   cidname=0xac4a7e60 "PATEL YAGNESH  ") at app_voicemail.c:4897
#18 0x0635766f in leave_voicemail (chan=0xac433a28, ext=0x1868c50
"5...@druid-default", options=0x1868dac) at app_voicemail.c:4085
#19 0x06358419 in vm_exec (chan=0xac433a28, data=0x186ae38) at
app_voicemail.c:7644
#20 0x080ccbeb in pbx_extension_helper (c=0xac433a28, con=0x0,
context=0xac433ba8 "macro-ael-myvoicemail", exten=0xac433bf8
"sw-43-NOANSWER", priority=10,
   label=0x0, callerid=0xabc5db40 "7134809419", action=E_SPAWN) at
pbx.c:537
#21 0x00d49069 in _macro_exec (chan=0xac433a28, data=<value optimized out>,
exclusive=0) at app_macro.c:308
#22 0x080ccbeb in pbx_extension_helper (c=0xac433a28, con=0x0,
context=0xac433ba8 "macro-ael-myvoicemail", exten=0xac433bf8
"sw-43-NOANSWER", priority=126,
   label=0x0, callerid=0xabc5db40 "7134809419", action=E_SPAWN) at
pbx.c:537
#23 0x00d49069 in _macro_exec (chan=0xac433a28, data=<value optimized out>,
exclusive=0) at app_macro.c:308
#24 0x080ccbeb in pbx_extension_helper (c=0xac433a28, con=0x0,
context=0xac433ba8 "macro-ael-myvoicemail", exten=0xac433bf8
"sw-43-NOANSWER", priority=1,
   label=0x0, callerid=0xabc5db40 "7134809419", action=E_SPAWN) at
pbx.c:537
#25 0x080cebf1 in __ast_pbx_run (c=0xac433a28) at pbx.c:2317
#26 0x080cfc1e in pbx_thread (data=0xac433a28) at pbx.c:2621
#27 0x080fe5cb in dummy_start (data=0xabc63b40) at utils.c:912
#28 0x00ea545b in start_thread () from /lib/libpthread.so.0
#29 0x00922e5e in clone () from /lib/libc.so.6



Thread 1 (process 18658):
#0  ucase (s=0x0) at misc.c:43
#1  0x016c4bc5 in imap_parse_unsolicited (stream=0xb7e5fa88,
reply=0xb7e650ec) at imap4r1.c:3596
#2  0x016c71cd in imap_reply (stream=0xb7e5fa88, tag=0x15ee676 "000017e0")
at imap4r1.c:3453
#3  0x016c7248 in imap_sout (stream=0xb7e5fa88, tag=0x15ee676 "000017e0",
base=0xb7e65140 "", s=0x15ee688) at imap4r1.c:3411
#4  0x016c8c5c in imap_send (stream=0xb7e5fa88, cmd=0x1739ad7 "FETCH",
args=0x15ee6c8) at imap4r1.c:3045
#5  0x016c901c in imap_fetch (stream=0xb7e5fa88, sequence=0xabcd1ce0 "1:7",
flags=<value optimized out>) at imap4r1.c:5427
#6  0x016cae08 in imap_search (stream=0xb7e5fa88, charset=0x0,
pgm=0xabc213e0, flags=<value optimized out>) at imap4r1.c:2076
#7  0x0169ddb3 in mail_search_full (stream=0xb7e5fa88, charset=0x0,
pgm=0xabc213e0, flags=<value optimized out>) at mail.c:2237
#8  0x0634ee58 in messagecount (context=0x15eedb5 "druid-default",
mailbox=0x15eedb0 "5026", folder=0x635f102 "Old") at app_voicemail.c:1232
#9  0x0634f612 in inboxcount (mailbox_context=0xb7e23880 "5...@druid-default",
newmsgs=0x15f1298, oldmsgs=0x15f1294) at app_voicemail.c:1389
#10 0x01e9b69b in sip_send_mwi_to_peer (peer=0xb7e23338) at chan_sip.c:16019
#11 0x01e9c12e in do_monitor (data=0x0) at chan_sip.c:16236
#12 0x080fe5cb in dummy_start (data=0x9d16778) at utils.c:912
#13 0x00ea545b in start_thread () from /lib/libpt


-- Mark --

http://panda.com/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.
_______________________________________________
Imap-uw mailing list
Imap-uw@u.washington.edu
http://mailman2.u.washington.edu/mailman/listinfo/imap-uw

Reply via email to