[asterisk-bugs] [Asterisk 0011044]: [crash] FreeBSD: Crash if compile with option DEBUG_THREADS DONT_OPTIMIZE MALLOC_DEBUG

noreply at bugs.digium.com noreply at bugs.digium.com
Mon Oct 22 10:05:27 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=11044 
====================================================================== 
Reported By:                ys
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   11044
Category:                   Core/BuildSystem
Reproducibility:            always
Severity:                   crash
Priority:                   normal
Status:                     new
Asterisk Version:           1.4.13  
SVN Branch (only for SVN checkouts, not tarball releases):  1.4  
SVN Revision (number only!):  
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             10-21-2007 10:55 CDT
Last Modified:              10-22-2007 10:05 CDT
====================================================================== 
Summary:                    [crash] FreeBSD: Crash if compile with option
DEBUG_THREADS DONT_OPTIMIZE MALLOC_DEBUG
Description: 
FreBSD 5_RELEASE and 6_RELEASE are crashed at startup , if asterisk
compiled with options DEBUG_THREADS and DONT_OPTIMIZE.

This can be always reproduced at any version of FreeBSD.

#./sbin/asterisk
Bus error (core dumped)

#gdb ./sbin/asterisk ./asterisk.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-marcel-freebsd"...
Core was generated by `asterisk'.
Program terminated with signal 10, Bus error.
Reading symbols from /lib/libncurses.so.5...done.
Loaded symbols for /lib/libncurses.so.5
Reading symbols from /lib/libm.so.3...done.
Loaded symbols for /lib/libm.so.3
Reading symbols from /lib/libcrypto.so.3...done.
Loaded symbols for /lib/libcrypto.so.3
Reading symbols from /usr/lib/libpthread.so.1...done.
Loaded symbols for /usr/lib/libpthread.so.1
Reading symbols from /lib/libc.so.5...done.
Loaded symbols for /lib/libc.so.5
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
http://bugs.digium.com/view.php?id=0  0x080bc834 in ast_log (level=4,
    file=0x813b7e0
"/home/asterisk2/src/asterisk-1.4/include/asterisk/lock.h",
    line=313, function=0x813bb94 "__ast_pthread_mutex_lock",
    fmt=0x813b888 "%s line %d (%s): Error: mutex '%s' is
uninitialized.\n")
    at logger.c:689
689             if (!(buf = ast_dynamic_str_thread_get(&log_buf,
LOG_BUF_INIT_SIZE)))

(gdb)bt 2 full
http://bugs.digium.com/view.php?id=0  0x080bc834 in ast_log (level=4,
    file=0x813b7e0
"/home/asterisk2/src/asterisk-1.4/include/asterisk/lock.h",
    line=313, function=0x813bb94 "__ast_pthread_mutex_lock",
    fmt=0x813b888 "%s line %d (%s): Error: mutex '%s' is
uninitialized.\n")
    at logger.c:689
        chan = (struct logchannel *) 0x283656bf
        buf = (struct ast_dynamic_str *) 0xbfa00308
        t = -1077941088
        tm = {tm_sec = 240, tm_min = 0, tm_hour = -1080032584,
  tm_mday = 674647487, tm_mon = 240, tm_year = 0, tm_wday = 0,
  tm_yday = 674647410, tm_isdst = 0, tm_gmtoff = 0, tm_zone = 0x0}
        date = '\0' <repeats 220 times>, "?J6(", '\0' <repeats 21 times>,
"\f\000\000\b\000\000\000?+=("
        ap = 0x0
        __PRETTY_FUNCTION__ = "ast_log"
http://bugs.digium.com/view.php?id=1  0x0807294c in __ast_pthread_mutex_lock
(filename=0x813b75f "astmm.c",
    lineno=120, func=0x813bc0c "__ast_alloc_region",
    mutex_name=0x813b774 "&reglock", t=0x816f780) at lock.h:312
        res = 674650024
        canlog = -11
        __PRETTY_FUNCTION__ = "__ast_pthread_mutex_lock"
(More stack frames follow...)

(gdb) frame 1
http://bugs.digium.com/view.php?id=1  0x0807294c in __ast_pthread_mutex_lock
(filename=0x813b75f "astmm.c",
    lineno=120, func=0x813bc0c "__ast_alloc_region",
    mutex_name=0x813b774 "&reglock", t=0x816f780) at lock.h:312
warning: Source file is more recent than executable.

312                     __ast_mutex_logger("%s line %d (%s): Error: mutex
'%s' is uninitialized.\n",
(gdb) t *p
No symbol "p" in current context.
(gdb) p *t
$1 = {mutex = 0x0, track = 0, file = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
0x0,
    0x0, 0x0}, lineno = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, reentrancy = 0,
  func = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, thread =
{0x0,
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, reentr_mutex = 0x0}







====================================================================== 

---------------------------------------------------------------------- 
 ys - 10-22-07 10:05  
---------------------------------------------------------------------- 
I upload patch, that fix the problemm in deadloop.

If reglock is is uninitialized, we have the loop:

ast_mutex_lock(&reglock) -> __ast_mutex_logger() -> ast_log() ->
__ast_calloc() -> __ast_alloc_region() -> ast_mutex_lock(&reglock) 

And, I don't understand why ast_mutex_lock(&reglock); can be called before
AST_MUTEX_DEFINE_STATIC_NOTRACKING(reglock); ? 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
10-22-07 10:05  ys             Note Added: 0072351                          
======================================================================




More information about the asterisk-bugs mailing list