asterisk / asterisk

The official Asterisk Project repository.
https://www.asterisk.org
Other
1.97k stars 924 forks source link

[bug]: segfault on start if compiled with DETECT_DEADLOCKS #719

Closed alex2grad closed 2 weeks ago

alex2grad commented 3 weeks ago

Severity

Trivial

Versions

18.22.0

Components/Modules

lock.c

Operating Environment

Slackware 15.0 x86_64

Frequency of Occurrence

Constant

Issue Description

If asterisk is compiled with DETECT_DEADLOCKS and without DEBUG_THREADS it's immediately crashes on startup.

CFLAGS="-g -Og -fPIC" \ CXXFLAGS="-g -Og -fPIC" \ ./configure \ --prefix=/usr \ --libdir=/usr/lib64 \ --sysconfdir=/etc \ --localstatedir=/var \ --mandir=/usr/man \ --with-pjproject-bundled \ --with-download-cache=/tmp/downloads \ --with-libedit=/usr \ --enable-dev-mode=yes \ --build=x86_64-slackware-linux

make menuselect.makeopts menuselect/menuselect \ --disable res_calendar_caldav \ --disable CORE-SOUNDS-EN-GSM \ --disable MOH-OPSOUND-WAV \ --enable DETECT_DEADLOCKS \ menuselect.makeopts

Relevant log output

# asterisk -fdvvvvvvvv
Seeding global EID 'xx:xx:xx:xx:xx:xx' from 'br0' using 'siocgifhwaddr'
Unable to open specified master config file '/etc/asterisk/asterisk.conf', using built-in defaults
Asterisk 18.22.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Manager registered action DBGet
Segmentation fault

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x0000000000465329 in __ao2_lock (user_data=user_data@entry=0x1, lock_how=lock_how@entry=AO2_LOCK_REQ_MUTEX, file=file@entry=0x637fb1 "astobj2.c", func=func@entry=0x638338 <__PRETTY_FUNCTION__.11> "__ao2_ref", line=line@entry=526, 
    var=var@entry=0x637fc7 "weakproxy") at astobj2.c:224
224             struct astobj2 *obj = __INTERNAL_OBJ_CHECK(user_data, file, line, func);
[Current thread is 1 (Thread 0x7fc41cce9780 (LWP 27706))]

(gdb) bt full
#0  0x0000000000465329 in __ao2_lock (user_data=user_data@entry=0x1, lock_how=lock_how@entry=AO2_LOCK_REQ_MUTEX, file=file@entry=0x637fb1 "astobj2.c", func=func@entry=0x638338 <__PRETTY_FUNCTION__.11> "__ao2_ref", line=line@entry=526, 
    var=var@entry=0x637fc7 "weakproxy") at astobj2.c:224
        p__LINE__ = 0xffffffffffffffe9
        obj = <optimized out>
        obj_mutex = <optimized out>
        obj_rwlock = <optimized out>
        obj_lockobj = <optimized out>
        res = <optimized out>
#1  0x00000000004658e7 in __ao2_ref (user_data=user_data@entry=0x2d5f330, delta=delta@entry=-1, tag=tag@entry=0x691970 "action object registration successful", file=file@entry=0x68d440 "manager.c", line=line@entry=8119, 
    func=func@entry=0x693050 <__PRETTY_FUNCTION__.159> "ast_manager_register2") at astobj2.c:526
        obj = 0x2d5f318
        obj_mutex = <optimized out>
        obj_rwlock = <optimized out>
        obj_lockobj = <optimized out>
        current_value = <optimized out>
        ret = <optimized out>
        privdataoptions = <optimized out>
        weakproxy = 0x1
        lock_state = <optimized out>
        __PRETTY_FUNCTION__ = "__ao2_ref"
#2  0x000000000062531f in ast_manager_register2 (action=action@entry=0x6503cc "DBGet", auth=auth@entry=513, func=func@entry=0x4d3e10 <manager_dbget>, module=module@entry=0x0, synopsis=synopsis@entry=0x0, 
    description=description@entry=0x0) at manager.c:8119
        cur = 0x2d5f330
        __PRETTY_FUNCTION__ = "ast_manager_register2"
#3  0x00000000004d5366 in astdb_init () at db.c:1242
        __PRETTY_FUNCTION__ = "astdb_init"
        __FUNCTION__ = "astdb_init"
#4  0x00000000004408e9 in asterisk_daemon (isroot=<optimized out>, rungroup=0x0, runuser=0x0) at asterisk.c:4179
        sigs = {__val = {0, 0, 14, 0, 140480280666656, 140480268919809, 140480273648912, 140721925579664, 832, 282584257676671, 0, 4299030531, 59984, 64, 195296, 15762873573703680}}
        buf = <optimized out>
        pbx_uuid = "\000\037#\035\304\177\000\000\304%8\035\304\177\000\000@\020:\035\304\177", '\000' <repeats 14 times>
        f = 0x1f3b980
        num = 0
        f = <optimized out>
        sigs = <optimized out>
        num = <optimized out>
        buf = <optimized out>
        pbx_uuid = <optimized out>
        __FUNCTION__ = "asterisk_daemon"
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        canary_binary = <optimized out>
        ppid = <optimized out>
        dont_care = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
--Type <RET> for more, q to quit, c to continue without paging--
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        title = <optimized out>
        hostname = <optimized out>
#5  main (argc=<optimized out>, argv=<optimized out>) at asterisk.c:4045
        c = <optimized out>
        x = <optimized out>
        isroot = <optimized out>
        rundir_exists = <optimized out>
        runuser = 0x0
        rungroup = 0x0
        xarg = 0x0
        l = {rlim_cur = 32768, rlim_max = 32768}
        getopt_settings = 0x636768 "BC:cde:FfG:ghIiL:M:mnpqRrs:TtU:VvWXx:"
        __PRETTY_FUNCTION__ = "main"
        __FUNCTION__ = "main"
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>
        __p = <optimized out>
        __x = <optimized out>

Asterisk Issue Guidelines

alex2grad commented 3 weeks ago

I want to check a new feature "no longer need to select DEBUG_THREADS to use DETECT_DEADLOCKS" https://github.com/asterisk/asterisk/pull/334 But it seems it's not working

alex2grad commented 3 weeks ago

@gtjoseph could you please look at this?

gtjoseph commented 3 weeks ago

@gtjoseph could you please look at this?

Yep. I'll check this afternoon

gtjoseph commented 3 weeks ago

Confirmed. I've opened an internal issue for this.

gtjoseph commented 3 weeks ago

@alex2grad Check the ADD_CFLAGS_TO_BUILDOPTS_H option along with DETECT_DEADLOCKS and see if that prevents the segfault. If it does, then I know what the issue is and will have a fix up shortly.

alex2grad commented 3 weeks ago

No segfault with menuselect/menuselect \ --disable res_calendar_caldav \ --disable CORE-SOUNDS-EN-GSM \ --disable MOH-OPSOUND-WAV \ --enable DETECT_DEADLOCKS \ --enable ADD_CFLAGS_TO_BUILDOPTS_H \ menuselect.makeopts