<div dir="ltr">It looks to me like it should have worked.<div><br></div><div>Maybe you do something wrong in the callback ? </div><div><br></div><div>Refer to other code that uses media bug, like mod_avmd .  </div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 6, 2019 at 7:03 PM David Horton <<a href="mailto:daveh@drachtio.org">daveh@drachtio.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">(Resending, as original email has not appeared in the mailing list)<br>
<br>
I’m trying to understand the semantics of removing and re-adding a media bug to a channel.<br>
<br>
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.  <br>
Based on other factors, some time later in the call, I may want to re-add it again.<br>
<br>
I am on Freeswitch v1.8.5<br>
<br>
How I am doing this now is:<br>
<br>
- switch_core_media_bug_add(session, “my-function”, NULL, callback, …)<br>
<br>
some time later<br>
<br>
- switch_core_media_bug_remove(session, &bug);<br>
<br>
some time later<br>
<br>
- switch_core_media_bug_add(session, “my-function”, NULL, callback, …)<br>
<br>
That all works fine, but when the session ends I get a segfault.  See the stack trace below.<br>
<br>
(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).<br>
<br>
So, two questions:<br>
<br>
1) What is the recommended way to accomplish what I am doing?<br>
2) Is this a bug in freeswitch that I should report via Confluence?<br>
<br>
Thread 40 "freeswitch" received signal SIGSEGV, Segmentation fault.<br>
[Switching to Thread 0x7fffee766700 (LWP 31704)]<br>
__GI___pthread_rwlock_unlock (rwlock=0x7fffc801acf0) at pthread_rwlock_unlock.c:38<br>
38      pthread_rwlock_unlock.c: No such file or directory.<br>
(gdb) bt<br>
#0  __GI___pthread_rwlock_unlock (rwlock=0x7fffc801acf0) at pthread_rwlock_unlock.c:38<br>
#1  0x00007ffff7658b6e in apr_thread_rwlock_unlock () from /usr/local/freeswitch/lib/libfreeswitch.so.1<br>
#2  0x00007ffff6fc2cf3 in switch_thread_rwlock_unlock (rwlock=0x7fffc801ace8) at src/switch_apr.c:279<br>
#3  0x00007ffff6fe3272 in switch_core_media_bug_remove_all_function (session=0x7fffc801c158, function=0x0)<br>
   at src/switch_core_media_bug.c:1231<br>
#4  0x00007ffff700a6f3 in switch_core_session_hangup_state (session=0x7fffc801c158, force=SWITCH_TRUE)<br>
   at src/switch_core_state_machine.c:838<br>
#5  0x00007ffff7007178 in switch_core_session_run (session=0x7fffc801c158)<br>
   at src/switch_core_state_machine.c:615<br>
#6  0x00007ffff700069e in switch_core_session_thread (thread=0x7fffc8041410, obj=0x7fffc801c158)<br>
   at src/switch_core_session.c:1698<br>
#7  0x00007ffff7000a8d in switch_core_session_thread_pool_worker (thread=0x7fffc8041410, obj=0x7fffc80412a0)<br>
   at src/switch_core_session.c:1761<br>
#8  0x00007ffff7660e1f in dummy_worker () from /usr/local/freeswitch/lib/libfreeswitch.so.1<br>
#9  0x00007ffff63554a4 in start_thread (arg=0x7fffee766700) at pthread_create.c:456<br>
#10 0x00007ffff5992d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97<br>
_________________________________________________________________________<br>
<br>
The FreeSWITCH project is sponsored by SignalWire <a href="https://signalwire.com" rel="noreferrer" target="_blank">https://signalwire.com</a><br>
Enhance your FreeSWITCH install with disruptive priced SMS and PSTN services.<br>
Build your next product on our scalable cloud platform.<br>
<br>
Join our online community to chat in real time <a href="https://signalwire.community" rel="noreferrer" target="_blank">https://signalwire.community</a><br>
<br>
Professional FreeSWITCH Services<br>
<a href="mailto:sales@freeswitch.com" target="_blank">sales@freeswitch.com</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="https://freeswitch.com/oss" rel="noreferrer" target="_blank">https://freeswitch.com/oss</a><br>
<a href="https://freeswitch.org/confluence" rel="noreferrer" target="_blank">https://freeswitch.org/confluence</a><br>
<a href="https://cluecon.com" rel="noreferrer" target="_blank">https://cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" rel="noreferrer" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="https://freeswitch.com" rel="noreferrer" target="_blank">https://freeswitch.com</a></blockquote></div>