New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debugger: kamailio freezes when dynamically setting module level(using fifo/rpc) #463
Comments
Also I've been comparing the lock_get()/release() for level vs facility without seeing any differences. But maybe I'm missing something. |
Can you attach with gdb to the locked process (probably the ctl handler) and get a backtrace from it? |
Sorry, I overlooked gdb: The deadlock makes sense. MDBG() in fm_malloc() issues dbg_get_mod_debug_level() which gets the same lock that dbg_set_mod_debug_level() already got. The first option would be to never use locks for dbg_get_mod_debug_level()(because the list is just iterated through, no list mutations). What do you think is the best option? |
This is a recursive access to the same slot in debugger hash table:
Solutions:
|
modparam("debugger", "mod_level", "core=2")
Don't shm_malloc() while the lock is taken.
Added fix with the second solution on pull-request #469. Basically tested it and the freeze is not happening anymore. However, the first solution can still be logged as an enhancement issue. If all is ok I will backport this to 4.X branches. |
I am fine with second solution fix, just needs to be kept in mind that no direct or indirect or direct LOG/DBG statements insides locked regions of debugger hash table. You can merge and close the related issues on tracker. |
Don't shm_malloc() while the lock is taken. (cherry picked from commit 3668618)
Don't shm_malloc() while the lock is taken. (cherry picked from commit 3668618)
Don't shm_malloc() while the lock is taken. (cherry picked from commit 3668618)
... if the module level is not previously set in config file:
modparam("debugger", "mod_level", "core=2")
This is not happening when setting the module facility, for the above, same conditions.
This is happening also before pull-request [1] using "kamcmd dbg.mod_level core 1".
After some debugging I've noticed that this is happening when trying to set a level for a module name whose
idx = hid&(_dbg_mod_table_size-1);
is even number?!, but not for one that reduces to an odd number (i.e. module name "core" reduces to an even index and "corex" to odd); the idx is always in the range_dbg_mod_table_size-1
as it should be.Trying to solve this, I commented the lock_get/release in
dbg_set_mod_debug_level()
and saw it's working; kamailio doesn't freeze anymore. Thus, I tried to refactor the locks instruct _dbg_mod_slot
to be dynamically allocated/deallocated using lock_alloc()/destroy() without success.I'm out of ideas. Do you have any idea what might lead to this strange deadlock?
[1] #462
The text was updated successfully, but these errors were encountered: