[Freeswitch-dev] crash running the core twice in one process

Anthony Minessale anthony.minessale at gmail.com
Wed Jul 1 16:00:42 PDT 2009


look in switch.c

we do it when you say "fsctl shutdown restart" and it works fine over and
over.



On Wed, Jul 1, 2009 at 5:52 PM, Tamas <jalsot at gmail.com> wrote:

> Hello,
>
> I'm trying to embed FS in a C application where I should have to restart
> the whole stuff (core) in one process/thread, however it crashes. I
> assume, something is not freed up before the new startup. I've used
> mrene's fshost example to reproduce the issue:
>
> Index: contrib/mrene/fshost/main.c
> ===================================================================
> --- contrib/mrene/fshost/main.c    (revision 14092)
> +++ contrib/mrene/fshost/main.c    (working copy)
>  -82,7 +82,34 @@
>
>         ret = system(buf);
>     }
> +
> +
> +    /* Here I start my 2nd start */
> +
> +    /* Initialize libs & globals */
> +    printf("Initializing globals...\n");
> +    switch_core_setrlimits();
> +    switch_core_set_globals();
>
> +    /* If you need to override configuration directories, you need to
> change them in the SWITCH_GLOBAL_dirs global structure */
> +    printf("Initializing core...\n");
> +    /* Initialize the core and load modules, that will startup FS
> completely */
> +    if (switch_core_init_and_modload(flags, console, &err) !=
> SWITCH_STATUS_SUCCESS) {
> +        fprintf(stderr, "Failed to initialize FreeSWITCH's core: %s\n",
> err);
> +        return 1;
> +    }
> +
> +    printf("Everything OK, Entering runtime loop.\n");
> +
> +    fflush(stdout);
> +
> +    /* Go into the runtime loop. If the argument is true, this
> basically sets runtime.running = 1 and loops while that is set
> +     * If its false, it initializes the libedit for the console, then
> does the same thing
> +     */
> +    switch_core_runtime_loop(!console);
> +
> +    /* When the runtime loop exits, its time to shutdown */
> +    destroy_status = switch_core_destroy();
>     return ret;
>  }
>
>  -95,4 +122,4 @@
>  * End:
>  * For VIM:
>  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
> - */
> \ No newline at end of file
> + */
>
>
> Here are some gdb backtraces:
>
> (gdb) bt
> #0  0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at misc/apr_queue.c:215
> #1  0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at src/switch_apr.c:931
> #2  0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,
> obj=0x12b8398) at src/switch_event.c:305
> #3  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at
> threadproc/unix/thread.c:138
> #4  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> #5  0x00007fb418933fcd in clone () from /lib/libc.so.6
> #6  0x0000000000000000 in ?? ()
> (gdb) bt full
> #0  0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at misc/apr_queue.c:215
>        rv = 0
> #1  0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at src/switch_apr.c:931
>        s = 0
> #2  0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,
> obj=0x12b8398) at src/switch_event.c:305
>        pop = 0x12b4b60
>        event = 0x12b4b60
>        queue = 0x12b8398
>        index = 0
>        my_id = 0
>        __func__ = "switch_event_thread"
> #3  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at
> threadproc/unix/thread.c:138
>        thread = 0x1663a98
> #4  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> No symbol table info available.
> #5  0x00007fb418933fcd in clone () from /lib/libc.so.6
> No symbol table info available.
> #6  0x0000000000000000 in ?? ()
> No symbol table info available.
>
>
> (gdb) thread apply all bt
>
> Thread 5 (Thread 31286):
> #0  0x00007fb41892c742 in select () from /lib/libc.so.6
> #1  0x00007fb418caab2a in apr_sleep (t=100000) at time/unix/time.c:246
> #2  0x00007fb418c7aba5 in do_sleep (t=100000) at src/switch_time.c:109
> #3  0x00007fb418c7ad95 in switch_sleep (t=100000) at src/switch_time.c:178
> #4  0x00007fb418c16b75 in pool_thread (thread=0x1417ff8, obj=0x0) at
> src/switch_core_memory.c:531
> #5  0x00007fb418ca8c01 in dummy_worker (opaque=0x1417ff8) at
> threadproc/unix/thread.c:138
> #6  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> #7  0x00007fb418933fcd in clone () from /lib/libc.so.6
> #8  0x0000000000000000 in ?? ()
>
> Thread 4 (Thread 31264):
> #0  0x00007fb417ffbbc5 in __lll_unlock_wake () from /lib/libpthread.so.0
> #1  0x00007fb417ff85c9 in _L_unlock_56 () from /lib/libpthread.so.0
> #2  0x00007fb417ff8206 in __pthread_mutex_unlock_usercnt () from
> /lib/libpthread.so.0
> #3  0x00007fb418ca12de in apr_thread_mutex_unlock (mutex=0x12b83d8) at
> locks/unix/thread_mutex.c:121
> #4  0x00007fb418c94b78 in apr_queue_trypush (queue=0x12b8398,
> data=0x12b4b60) at misc/apr_queue.c:242
> #5  0x00007fb418c0464a in switch_queue_trypush (queue=0x12b8398,
> data=0x12b4b60) at src/switch_apr.c:931
> #6  0x00007fb418c3dfe8 in switch_event_fire_detailed
> (file=0x7fb418d55ce0 "src/switch_xml.c", func=0x7fb418d562f0
> "switch_xml_open_root", line=1918, event=0x7fff211d0a58, user_data=0x0)
>    at src/switch_event.c:1128
> #7  0x00007fb418c76a66 in switch_xml_open_root (reload=0 '\0',
> err=0x7fff211d1110) at src/switch_xml.c:1918
> #8  0x00007fb418c76b5e in switch_xml_init (pool=0x126aff8,
> err=0x7fff211d1110) at src/switch_xml.c:1945
> #9  0x00007fb418c2d78f in switch_core_init (flags=1,
> console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1231
> #10 0x00007fb418c2e02b in switch_core_init_and_modload (flags=1,
> console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1422
> #11 0x0000000000400ed7 in main (argc=1, argv=0x7fff211d1628) at main.c:97
>
> Thread 3 (Thread 31288):
> #0  0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from
> /lib/libpthread.so.0
> #1  0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x14dbb08,
> mutex=0x14dbab8) at locks/unix/thread_cond.c:68
> #2  0x00007fb418c94c1f in apr_queue_pop (queue=0x14dba78,
> data=0x7fb41676c0b8) at misc/apr_queue.c:276
> #3  0x00007fb418c045ca in switch_queue_pop (queue=0x14dba78,
> data=0x7fb41676c0b8) at src/switch_apr.c:902
> #4  0x00007fb418c3ba5e in switch_event_thread (thread=0x1663ac8,
> obj=0x14dba78) at src/switch_event.c:289
> #5  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663ac8) at
> threadproc/unix/thread.c:138
> #6  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> #7  0x00007fb418933fcd in clone () from /lib/libc.so.6
> #8  0x0000000000000000 in ?? ()
>
> Thread 2 (Thread 31289):
> #0  0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from
> /lib/libpthread.so.0
> #1  0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x159fb18,
> mutex=0x159fac8) at locks/unix/thread_cond.c:68
> #2  0x00007fb418c94c1f in apr_queue_pop (queue=0x159fa88,
> data=0x7fb4167a80b8) at misc/apr_queue.c:276
> #3  0x00007fb418c045ca in switch_queue_pop (queue=0x159fa88,
> data=0x7fb4167a80b8) at src/switch_apr.c:902
> #4  0x00007fb418c3ba5e in switch_event_thread (thread=0x1663af8,
> obj=0x159fa88) at src/switch_event.c:289
> #5  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663af8) at
> threadproc/unix/thread.c:138
> #6  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> #7  0x00007fb418933fcd in clone () from /lib/libc.so.6
> #8  0x0000000000000000 in ?? ()
>
> Thread 1 (Thread 31287):
> #0  0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at misc/apr_queue.c:215
> #1  0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at src/switch_apr.c:931
> #2  0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,
> obj=0x12b8398) at src/switch_event.c:305
> #3  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at
> threadproc/unix/thread.c:138
> #4  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> #5  0x00007fb418933fcd in clone () from /lib/libc.so.6
> #6  0x0000000000000000 in ?? ()
>
> (gdb) thread apply all bt full
>
> Thread 5 (Thread 31286):
> #0  0x00007fb41892c742 in select () from /lib/libc.so.6
> No symbol table info available.
> #1  0x00007fb418caab2a in apr_sleep (t=100000) at time/unix/time.c:246
>        tv = {tv_sec = 0, tv_usec = 88462}
> #2  0x00007fb418c7aba5 in do_sleep (t=100000) at src/switch_time.c:109
> No locals.
> #3  0x00007fb418c7ad95 in switch_sleep (t=100000) at src/switch_time.c:178
> No locals.
> #4  0x00007fb418c16b75 in pool_thread (thread=0x1417ff8, obj=0x0) at
> src/switch_core_memory.c:531
>        len = 0
> #5  0x00007fb418ca8c01 in dummy_worker (opaque=0x1417ff8) at
> threadproc/unix/thread.c:138
>        thread = 0x1417ff8
> #6  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> No symbol table info available.
> #7  0x00007fb418933fcd in clone () from /lib/libc.so.6
> No symbol table info available.
> #8  0x0000000000000000 in ?? ()
> No symbol table info available.
>
> Thread 4 (Thread 31264):
> #0  0x00007fb417ffbbc5 in __lll_unlock_wake () from /lib/libpthread.so.0
> No symbol table info available.
> #1  0x00007fb417ff85c9 in _L_unlock_56 () from /lib/libpthread.so.0
> No symbol table info available.
> #2  0x00007fb417ff8206 in __pthread_mutex_unlock_usercnt () from
> /lib/libpthread.so.0
> No symbol table info available.
> #3  0x00007fb418ca12de in apr_thread_mutex_unlock (mutex=0x12b83d8) at
> locks/unix/thread_mutex.c:121
>        status = 0
> #4  0x00007fb418c94b78 in apr_queue_trypush (queue=0x12b8398,
> data=0x12b4b60) at misc/apr_queue.c:242
>        rv = 0
> #5  0x00007fb418c0464a in switch_queue_trypush (queue=0x12b8398,
> data=0x12b4b60) at src/switch_apr.c:931
>        s = 0
> #6  0x00007fb418c3dfe8 in switch_event_fire_detailed
> (file=0x7fb418d55ce0 "src/switch_xml.c", func=0x7fb418d562f0
> "switch_xml_open_root", line=1918, event=0x7fff211d0a58, user_data=0x0)
>    at src/switch_event.c:1128
>        was = 0
>        index = 0
>        __PRETTY_FUNCTION__ = "switch_event_fire_detailed"
>        __func__ = "switch_event_fire_detailed"
> #7  0x00007fb418c76a66 in switch_xml_open_root (reload=0 '\0',
> err=0x7fff211d1110) at src/switch_xml.c:1918
>        event = 0x12b4b60
>        path_buf =
>
> "/opt/freeswitch/conf/freeswitch.xml\0\0\0\0\0\340\33\"\1\0\0\0\0\0\320\34\31\264\177\0\0)'\214\30\264\177\0\0\6\0\0\0\b\0\0\1\200\247\273\30\264\177\0\0\0\0\0\0\0\0\0\0\340\33\"\1\0\0\0\0O\0\0\0\0\0\0\0\271\24\214\0\0\4\0\0`\6\35!\377\177\0\0@
> \16\35!\377\177\0\0\340\33\"\1\0\0\0\0\0\272\273\30\264\177\0\0p\r\35!\377\177\0\0`\v@
> \0\0\0\0\0
> \26\35!\377\177", '\0' <repeats 18 times>,
>
> "v\202\214\30\264\177\0\0\71\0\0\0\0\0\0\0\224\t\307\30\264\177\0\0\65\2\0\0\60\0\0\0\200\0\0\0\377\177\0\0\6\0\325\30\264\177\0\0\263\352\16\0\377\177\0\0\320\v\35!\377"...
>        hasmain = 0 '\0'
>        errcnt = 0 '\0'
>        new_main = 0x1221ca0
>        r = 0x0
>        __func__ = "switch_xml_open_root"
> #8  0x00007fb418c76b5e in switch_xml_init (pool=0x126aff8,
> err=0x7fff211d1110) at src/switch_xml.c:1945
>        xml = 0x12b8338
>        __PRETTY_FUNCTION__ = "switch_xml_init"
> ---Type <return> to continue, or q <return> to quit---
> #9  0x00007fb418c2d78f in switch_core_init (flags=1,
> console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1231
>        uuid = {data = "\0\0\0\0\0\0\0\0\200\247\273\30\264\177\0"}
>        guess_ip = "::1\0\61\66\70.69.69", '\0' <repeats 187
> times>"\331,
>
> _\222\30\264\177\0\0\0\0\0\0\0\0\0\0\25\0\0\0\0\0\0\0\0\320\34\31\264\177\0\0\25",
> '\0' <repeats 15 times>, "J\30\214\30\264\177\0"
>        dir_path = 0x0
>        mask = 16777215
>        in = {s_addr = 16777215}
>        __PRETTY_FUNCTION__ = "switch_core_init"
> #10 0x00007fb418c2e02b in switch_core_init_and_modload (flags=1,
> console=SWITCH_TRUE, err=0x7fff211d1110) at src/switch_core.c:1422
>        event = 0x400b60
>        __func__ = "switch_core_init_and_modload"
> #11 0x0000000000400ed7 in main (argc=1, argv=0x7fff211d1628) at main.c:97
>        flags = 1
>        err = 0x7fb418d56314 "Success"
>        console = SWITCH_TRUE
>        destroy_status = SWITCH_STATUS_SUCCESS
>        ret = 0
>        __PRETTY_FUNCTION__ = "main"
>
> Thread 3 (Thread 31288):
> #0  0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from
> /lib/libpthread.so.0
> No symbol table info available.
> #1  0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x14dbb08,
> mutex=0x14dbab8) at locks/unix/thread_cond.c:68
>        rv = 0
> #2  0x00007fb418c94c1f in apr_queue_pop (queue=0x14dba78,
> data=0x7fb41676c0b8) at misc/apr_queue.c:276
>        rv = 0
> #3  0x00007fb418c045ca in switch_queue_pop (queue=0x14dba78,
> data=0x7fb41676c0b8) at src/switch_apr.c:902
> No locals.
> #4  0x00007fb418c3ba5e in switch_event_thread (thread=0x1663ac8,
> obj=0x14dba78) at src/switch_event.c:289
>        pop = 0x0
>        event = 0x0
>        queue = 0x14dba78
>        index = 0
>        my_id = 1
>        __func__ = "switch_event_thread"
> #5  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663ac8) at
> threadproc/unix/thread.c:138
>        thread = 0x1663ac8
> #6  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> No symbol table info available.
> #7  0x00007fb418933fcd in clone () from /lib/libc.so.6
> No symbol table info available.
> #8  0x0000000000000000 in ?? ()
> No symbol table info available.
>
> Thread 2 (Thread 31289):
> #0  0x00007fb417ff92e9 in pthread_cond_wait@@GLIBC_2.3.2 () from
> /lib/libpthread.so.0
> No symbol table info available.
> #1  0x00007fb418ca13ef in apr_thread_cond_wait (cond=0x159fb18,
> mutex=0x159fac8) at locks/unix/thread_cond.c:68
>        rv = 0
> #2  0x00007fb418c94c1f in apr_queue_pop (queue=0x159fa88,
> data=0x7fb4167a80b8) at misc/apr_queue.c:276
>        rv = 0
> #3  0x00007fb418c045ca in switch_queue_pop (queue=0x159fa88,
> data=0x7fb4167a80b8) at src/switch_apr.c:902
> No locals.
> #4  0x00007fb418c3ba5e in switch_event_thread (thread=0x1663af8,
> obj=0x159fa88) at src/switch_event.c:289
> ---Type <return> to continue, or q <return> to quit---
>        pop = 0x0
>        event = 0x0
>        queue = 0x159fa88
>        index = 0
>        my_id = 2
>        __func__ = "switch_event_thread"
> #5  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663af8) at
> threadproc/unix/thread.c:138
>        thread = 0x1663af8
> #6  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> No symbol table info available.
> #7  0x00007fb418933fcd in clone () from /lib/libc.so.6
> No symbol table info available.
> #8  0x0000000000000000 in ?? ()
> No symbol table info available.
>
> Thread 1 (Thread 31287):
> #0  0x00007fb418c94a7f in apr_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at misc/apr_queue.c:215
>        rv = 0
> #1  0x00007fb418c0464a in switch_queue_trypush (queue=0x7fb4168e45a8,
> data=0x12b4b60) at src/switch_apr.c:931
>        s = 0
> #2  0x00007fb418c3bab8 in switch_event_thread (thread=0x1663a98,
> obj=0x12b8398) at src/switch_event.c:305
>        pop = 0x12b4b60
>        event = 0x12b4b60
>        queue = 0x12b8398
>        index = 0
>        my_id = 0
>        __func__ = "switch_event_thread"
> #3  0x00007fb418ca8c01 in dummy_worker (opaque=0x1663a98) at
> threadproc/unix/thread.c:138
>        thread = 0x1663a98
> #4  0x00007fb417ff53ba in start_thread () from /lib/libpthread.so.0
> No symbol table info available.
> #5  0x00007fb418933fcd in clone () from /lib/libc.so.6
> No symbol table info available.
> #6  0x0000000000000000 in ?? ()
> No symbol table info available.
>
>
> FS svn r14092, gcc-4.3.3, x86_64
>
> Any idea what should I add to free up everything after shutdown and lets
> start with "blank list"?
>
> Thanks in advance,
>    Tamas
>
>
> _______________________________________________
> Freeswitch-dev mailing list
> Freeswitch-dev at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
> http://www.freeswitch.org
>



-- 
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale at hotmail.com <MSN%3Aanthony_minessale at hotmail.com>
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<PAYPAL%3Aanthony.minessale at gmail.com>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org <sip%3A888 at conference.freeswitch.org>
iax:guest at conference.freeswitch.org/888
googletalk:conf+888 at conference.freeswitch.org<googletalk%3Aconf%2B888 at conference.freeswitch.org>
pstn:213-799-1400
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20090701/fafd7527/attachment-0001.html 


More information about the Freeswitch-dev mailing list