[Home]

Summary:ASTERISK-18479: ast_manager_register_struct attempts to unlock an uninitialized rwlock
Reporter:Jaco Kroon (jkroon)Labels:
Date Opened:2011-09-08 09:32:15Date Closed:2011-10-11 13:29:25
Priority:MajorRegression?
Status:Closed/CompleteComponents:Core/ManagerInterface
Versions:1.8.6.0 Frequency of
Occurrence
Constant
Related
Issues:
causesASTERISK-19487 AMI module reload causes deadlock
causesASTERISK-20677 Action Challenge not working with allowmultiplelogin=no
Environment:Attachments:
Description:Hi,

Whilst trying to track another issue, helgrind came across this during asterisk startup.

==9900== Thread #1 unlocked an invalid lock at 0x7E7DB0
==9900==    at 0x4C2B686: pthread_rwlock_unlock (hg_intercepts.c:1592)
==9900==    by 0x4DC0E1: ast_manager_register_struct (manager.c:5036)
==9900==    by 0x4EF7A4: ast_manager_register2 (manager.c:5088)
==9900==    by 0x498A74: ast_data_init (data.c:3290)
==9900==    by 0x440F79: main (asterisk.c:3740)
==9900==
==9900== Thread #1 unlocked an invalid lock at 0x7E7DB0
==9900==    at 0x4C2B686: pthread_rwlock_unlock (hg_intercepts.c:1592)
==9900==    by 0x4DC0E1: ast_manager_register_struct (manager.c:5036)
==9900==    by 0x4DC712: ast_manager_register2.clone.19 (manager.c:5088)
==9900==    by 0x4EE491: __init_manager (manager.c:6244)
==9900==    by 0x440FB4: main (asterisk.c:3759)
==9900==
==9900== Thread #1 unlocked an invalid lock at 0x7E7DB0
==9900==    at 0x4C2B686: pthread_rwlock_unlock (hg_intercepts.c:1592)
==9900==    by 0x4DC0E1: ast_manager_register_struct (manager.c:5036)
==9900==    by 0x4DC712: ast_manager_register2.clone.19 (manager.c:5088)
==9900==    by 0x4EE4A2: __init_manager (manager.c:6245)
==9900==    by 0x440FB4: main (asterisk.c:3759)

This repeats for pretty much every call coming into manager.c to register new actions, similar to:

==9900== Thread #1 unlocked an invalid lock at 0x7E7DB0
==9900==    at 0x4C2B686: pthread_rwlock_unlock (hg_intercepts.c:1592)
==9900==    by 0x4DC0E1: ast_manager_register_struct (manager.c:5036)
==9900==    by 0x4EF7A4: ast_manager_register2 (manager.c:5088)
==9900==    by 0x23CC63E4: load_module (chan_sip.c:29567)
==9900==    by 0x4D4262: start_resource (loader.c:785)
==9900==    by 0x4D48A6: load_resource_list (loader.c:973)
==9900==    by 0x4D62D4: load_modules (loader.c:1126)
==9900==    by 0x441083: main (asterisk.c:3824)
Comments:By: Richard Mudgett (rmudgett) 2011-10-11 13:19:50.255-0500

This helgrind report is a false positive.  That lock is statically initialized.  I have changed the code to not use the AST_RWLIST_TIMEDWRLOCK() anymore.  (Added because of ASTERISK-13784)

However, in examining the code to see what could be done about it I found several other issues.