AllStarLink / app_rpt

Refactoring and upgrade of AllStarLink's app_rpt, etc.
4 stars 2 forks source link

rpt_manager.c: Segfault due to dereferencing NULL channel #268

Closed InterLinked1 closed 6 months ago

InterLinked1 commented 6 months ago

Because we try to access a channel's variables without holding the node lock, this can lead to the channel becoming NULL during a module unload while we are trying to access it. This leads to a NULL dereference:

Thread 1 (Thread 0x7f0769a97700 (LWP 2629189)):
#0  rpt_manager_do_xstat (ses=0x7f0769a96cb0, m=0x7f0769a967e0, str=0x7f07840a5590 'U' <repeats 200 times>...) at app_rpt/rpt_manager.c:295
        rxchan = 0x7f07840ca9a0
        rxchanname = "Voter/2509000sb_25334", '000' <repeats 236 times>
        pseudo = 0
        i = 0
        j = 0
        ns = 0
        lbuf = '000' <repeats 240 times>...
        strs = {0x0 <repeats 5000 times>, 0x7f0769a94da0 "001200255", <incomplete sequence 373>, 0xc <error: Cannot access memory at address 0xc>, 0x7f07aed3f9fb <fmt+11> "", 0x7f07aed6e540 <_IO_str_jumps> "", 0x7>
        myrpt = 0x7f076f39a400 <rpt_vars>
        newvariable = 0x7f076f38d229
        connstate = 0x2b3eebbd9d7 <error: Cannot access memory at address 0x2b3eebbd9d7>
        l = 0x7f076f39bec8 <rpt_vars+6856>
        s = 0x7f0769a8a8e0
        t = 0x5619eeaf7018 <__ast_alloc_region+596>
        s_head = {next = 0x7f0769a8a8e0, prev = 0x7f0769a8a8e0, peer = '000' <repeats 30 times>, name = '000' <repeats 299 times>, mode = 0 '000', outbound = 0 '000', reconnects = 0, thisconnected = 0 '000', conne>
        node = 0x7f07840e7136 "2509"
        nrpts = 2
        parrot_ena = 0x7f076f38d369 "0"
        sys_ena = 0x7f076f38d369 "0"
        tot_ena = 0x7f076f38d369 "0"
        link_ena = 0x7f076f38d369 "0"
        patch_ena = 0x7f076f38d369 "0"
        patch_state = 0x7f076f38d36f "4"
        sch_ena = 0x7f076f38d369 "0"
        user_funs = 0x7f076f38d369 "0"
        tail_type = 0x7f076f38d369 "0"
        iconns = 0x7f076f38d369 "0"
        tot_state = 0x7f076f38d367 "1"
        ider_state = 0x7f076f38d36b "2"
        tel_mode = 0x7f076f38d367 "1"
        __PRETTY_FUNCTION__ = "rpt_manager_do_xstat"
        __FUNCTION__ = "rpt_manager_do_xstat"
#1  0x00007f076f365a35 in manager_rpt_status (s=0x7f0769a96cb0, m=0x7f0769a967e0) at app_rpt/rpt_manager.c:762