[Freeswitch-users] question on media bugs: add / remove /add sequence leading to crash when session ends

Dave Horton daveh at beachdognet.com
Fri Sep 6 13:57:31 UTC 2019


I’m trying to understand the semantics of removing and re-adding a media bug to a channel.

My scenario is that I need to add a bug to a session, and after some period of processing audio then want to remove it.  
Based on other factors, some time later in the call, I may want to re-add it again.

I am on Freeswitch v1.8.5

How I am doing this now is:

- switch_core_media_bug_add(session, “my-function”, NULL, callback, …)

some time later

- switch_core_media_bug_remove(session, &bug);

some time later

- switch_core_media_bug_add(session, “my-function”, NULL, callback, …)

That all works fine, but when the session ends I get a segfault.  See the stack trace below.

(Note: I also tried using ‘switch_core_media_bug_close’ for the second step, and I don’t get a stack trace in that scenario, but neither does my callback get invoked after I re-add the bug in step #3).

So, two questions:

1) What is the recommended way to accomplish what I am doing?
2) Is this a bug in freeswitch that I should report via Confluence?

Thread 40 "freeswitch" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffee766700 (LWP 31704)]
__GI___pthread_rwlock_unlock (rwlock=0x7fffc801acf0) at pthread_rwlock_unlock.c:38
38	pthread_rwlock_unlock.c: No such file or directory.
(gdb) bt
#0  __GI___pthread_rwlock_unlock (rwlock=0x7fffc801acf0) at pthread_rwlock_unlock.c:38
#1  0x00007ffff7658b6e in apr_thread_rwlock_unlock () from /usr/local/freeswitch/lib/libfreeswitch.so.1
#2  0x00007ffff6fc2cf3 in switch_thread_rwlock_unlock (rwlock=0x7fffc801ace8) at src/switch_apr.c:279
#3  0x00007ffff6fe3272 in switch_core_media_bug_remove_all_function (session=0x7fffc801c158, function=0x0)
    at src/switch_core_media_bug.c:1231
#4  0x00007ffff700a6f3 in switch_core_session_hangup_state (session=0x7fffc801c158, force=SWITCH_TRUE)
    at src/switch_core_state_machine.c:838
#5  0x00007ffff7007178 in switch_core_session_run (session=0x7fffc801c158)
    at src/switch_core_state_machine.c:615
#6  0x00007ffff700069e in switch_core_session_thread (thread=0x7fffc8041410, obj=0x7fffc801c158)
    at src/switch_core_session.c:1698
#7  0x00007ffff7000a8d in switch_core_session_thread_pool_worker (thread=0x7fffc8041410, obj=0x7fffc80412a0)
    at src/switch_core_session.c:1761
#8  0x00007ffff7660e1f in dummy_worker () from /usr/local/freeswitch/lib/libfreeswitch.so.1
#9  0x00007ffff63554a4 in start_thread (arg=0x7fffee766700) at pthread_create.c:456
#10 0x00007ffff5992d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97




More information about the FreeSWITCH-users mailing list