[Home]

Summary:ASTERISK-10728: DEBUG_THREADLOCALS: lock in main/threadstorage.c must be untracked?
Reporter:Yuri (ys)Labels:
Date Opened:2007-11-09 07:32:22.000-0600Date Closed:2007-12-05 11:47:34.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:CDR/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) threadstorage.c.diff
Description:I compile asterisk with DEBUG_THREADS, DEBUG_THREADLOCALS, DONT_OPTIMIZE.

When some thread stoped and thread destructor called, __ast_threadstorage_object_remove hold the lock "&(&tls_objects)->lock" and tracking information about this lock are placed into thread storage at function: ast_store_lock_info() from util.c .

So, thread destructor can't remove all "thread-specific data", and call destructor again and again...

Conclusively, kernel kill thread with warning:
"Thread 81ea600 has exited with leftover thread-specific data after 4 destructor iterations".

Also, if MALLOC_DEBUG enabled, the "lock_info->thread_name" are unallocated in this case. And memory debuger report error: "WARNING: Freeing unused memory at ...."


****** ADDITIONAL INFORMATION ******


I test this case with http thread, and add some testpoint, with fprintf(), into source code.
This is order of call at moment, where thread are exited:

lock_info_destroy():  lock_info->thread_name: ast_httpd_helper_thread started at [  625] http.c http_root()

ast_store_lock_info(): from: threadstorage.c line 78 (__ast_threadstorage_object_remove) lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'
ast_store_lock_info(): from: threadstorage.c line 78 (__ast_threadstorage_object_remove) lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'
ast_store_lock_info(): from: threadstorage.c line 78 (__ast_threadstorage_object_remove) lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'
ast_store_lock_info(): from: threadstorage.c line 69 (__ast_threadstorage_object_add) lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'
ast_store_lock_info(): from: threadstorage.c line 78 (__ast_threadstorage_object_remove) lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'

lock_info_destroy(): lock_info->thread_name:  0x0 (null)

ast_store_lock_info(): from: threadstorage.c line 69 (__ast_threadstorage_object_add): lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'
ast_store_lock_info(): from: threadstorage.c line 78 (__ast_threadstorage_object_remove): lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'

lock_info_destroy(): lock_info->thread_name:  0x0 (null)

ast_store_lock_info(): from: threadstorage.c line 69 (__ast_threadstorage_object_add): lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'
ast_store_lock_info(): from: threadstorage.c line 78 (__ast_threadstorage_object_remove): lock_info->thread_id: 0x0, lock_name: '&(&tls_objects)->lock'

lock_info_destroy(): lock_info->thread_name: 0x0 (null)
Thread 81ea600 has exited with leftover thread-specific data after 4 destructor iterations
Comments:By: Yuri (ys) 2007-11-09 07:33:02.000-0600

I mean Core/General :)

By: Yuri (ys) 2007-11-09 07:54:31.000-0600

I upload changes in threadstorage.c according as in astmm.c file.

By: Digium Subversion (svnbot) 2007-12-05 11:29:24.000-0600

Repository: asterisk
Revision: 91192

U   branches/1.4/main/threadstorage.c

------------------------------------------------------------------------
r91192 | russell | 2007-12-05 11:29:24 -0600 (Wed, 05 Dec 2007) | 10 lines

Make the lock in the threadstorage debugging code untracked to avoid a deadlock
on thread destruction.

(closes issue ASTERISK-10728)
Reported by: ys
Patches:
     threadstorage.c.diff uploaded by ys (license 281)

Also fixes an open bug report: (closes issue ASTERISK-10973)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=91192

By: Digium Subversion (svnbot) 2007-12-05 11:46:20.000-0600

Repository: asterisk
Revision: 91197

_U  trunk/
U   trunk/main/threadstorage.c

------------------------------------------------------------------------
r91197 | russell | 2007-12-05 11:46:19 -0600 (Wed, 05 Dec 2007) | 18 lines

Merged revisions 91192 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r91192 | russell | 2007-12-05 11:31:42 -0600 (Wed, 05 Dec 2007) | 10 lines

Make the lock in the threadstorage debugging code untracked to avoid a deadlock
on thread destruction.

(closes issue ASTERISK-10728)
Reported by: ys
Patches:
     threadstorage.c.diff uploaded by ys (license 281)

Also fixes an open bug report: (closes issue ASTERISK-10956)

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=91197

By: Digium Subversion (svnbot) 2007-12-05 11:47:34.000-0600

Repository: asterisk
Revision: 91192

U   branches/1.4/main/threadstorage.c

------------------------------------------------------------------------
r91192 | russell | 2007-12-05 11:31:42 -0600 (Wed, 05 Dec 2007) | 10 lines

Make the lock in the threadstorage debugging code untracked to avoid a deadlock
on thread destruction.

(closes issue ASTERISK-10728)
Reported by: ys
Patches:
     threadstorage.c.diff uploaded by ys (license 281)

Also fixes an open bug report: (closes issue ASTERISK-10956)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=91192