On Thu, Jul 10, 2008 at 1:25 AM, Gaurav Gupta <gg2265 at columbia.edu> wrote: > Hi All, > > When one uses PJSIP with another application, one has to register threads. > > thread_tls_id is a static variable in os_core_win32.cpp. It holds > thread id of last thread created or registered. > > > When a new thread is created, thread_tls_id holds its id. > > Consider this sequence of events: > > 1. main thread, thread_tls_id =1 > 2. new thread created, thread_tls_id=2, > 3. second thread completes, thread_tls_id=2 > 4. main thread calls PJ_CHECK_STACK, there is no thread corresponding > to id=2, so application crashes. > > I feel thread_tls_id should not be static in first place. > > What do the experts think ? > > Thanks, but we're not expert. :) I'm not sure which pjlib version you're using, but that's not the right interpretation of thread_tls_id (in the latest SVN at least). The thread_tls_id value is initialized once when pj_init() is called, when the pj_thread_init() function is called, and the value remains constant until pj_shutdown() is called. Subsequent thread creation will only associate thread specific data to this thread_tls_id index, and must not change the value of thread_tls_id itself. If thread_tls_id value is changed, things will break. Cheers Benny > -Gaurav > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080710/93b2533c/attachment.html