malloc/free deadlock bug

Gergely, KOVACS (VBuster) gkovacs at
Wed Feb 2 03:17:20 PST 2005

Dear FreeBSD people,

I have a multi threaded program (an Anti-Virus for Sendmail with Milter
API compiled with gcc 3.4.2). The threads are created by Sendmail's
libmilter, and the number of threads is limited to 100
(MaxDaemonChildren is set to 100 in

The hardware environment is a dual Xeon 3Ghz, and the OS is FreeBSD 5.3
with SMP enabled kernel.

The problem is that around in every 10th hour (100000 mail process) a
deadlock has been happened. According to gdb all threads are waiting in
malloc's, or free's mutex handler function:

#0  0x280b3c93 in pthread_mutexattr_init () from
#1  0x280b3be5 in pthread_mutexattr_init () from
#2  0x280b04bb in _pthread_mutex_trylock () from
#3  0x280b15e7 in pthread_mutex_lock () from /usr/lib/
#4  0x280a9b87 in _spinlock () from /usr/lib/
#5  0x2811c4a1 in ldexp () from /lib/
#6  0x2811c6d8 in malloc () from /lib/


#6  0x2811c704 in free () from /lib/

How can I fix this?

Best Regards,
Gergely Kovacs

More information about the freebsd-bugs mailing list