Summary: | ASTERISK-00589: Deadlock, presumable because of ast_debug() | ||
Reporter: | cdegroot (cdegroot) | Labels: | |
Date Opened: | 2003-11-27 16:47:52.000-0600 | Date Closed: | 2004-09-25 02:55:01 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Core/General |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) ast-thread-dump.txt ( 1) logger_deadlock.patch | |
Description: | (note: this is an interpretation of the attached file. I think it's correct, but I haven't done a lot of C/threads code lately) When debugging is on, * is in ast_log() and a sigurg comes in, ast_log() is called again and the system deadlocks on loglock. ****** ADDITIONAL INFORMATION ****** Solution suggestions: 1. suppress signals before ast_mutex_lock(&loglock) and enable again after it; 2. (better, probably) set a static flag when inside ast_log and just return when it's set: if (inside_log) return; inside_log = 1; ast_mutex_lock(&loglock); .... ast_mutex_unlock(&loglock); inside_log = 0; | ||
Comments: | By: Mark Spencer (markster) 2003-11-30 17:51:26.000-0600 Dead on. It never occured to me how we could ever deadlock inside ast_log. Is it a sufficient workaround to never ast_log inside a signal handler? By: cdegroot (cdegroot) 2003-12-01 01:47:11.000-0600 Well, I'd rather see ast_log protect itself against a deadlock, at least in that way you have "deadlock insurance" in a single place of the code. But if you can be sure that you cover all the places - for now and in the future - where ast_log() is called inside a signal handler, that should be just fine. By: Paul Cadach (pcadach) 2003-12-01 04:32:01.000-0600 2Mark: Asterisk gets dead by ast_log() lock when you run it with -d argument and tries to do 'stop now'. 100% reproducible (for me, at least). Also, I think current realization of inside_log variable manipulation isn't thread-safe and must be "mutexted" too. ;-)' By: ww (ww) 2003-12-05 14:55:09.000-0600 try the attached patch. it implements the static variable described by cdegroot and should fix the deadlock. really we want a mutex function like ast_mutex_islocked(&lock) By: ww (ww) 2003-12-05 15:03:22.000-0600 silly me. we do have such a function: ast_mutex_trylock() and it is thread safe. the logger_deadlock.patch contains this fix. By: zoa (zoa) 2004-01-09 21:48:39.000-0600 i just ran asterisk -vvvvvvvvvvvvvvvvvvgcd and did a stop now, didnt see any deadlock so i suppose this got fixed ? By: zoa (zoa) 2004-01-09 21:48:40.000-0600 i just ran asterisk -vvvvvvvvvvvvvvvvvvgcd and did a stop now, didnt see any deadlock so i suppose this got fixed ? By: jrollyson (jrollyson) 2004-01-14 03:37:54.000-0600 No longer able to duplicate, presumably fixed in cvs, let me know if you find otherwise. |