From patchwork Wed Aug 17 12:27:48 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marcel Wiesweg X-Patchwork-Id: 11979 Received: from pop.gmx.de ([213.165.64.20] helo=mail.gmx.net) by www.linuxtv.org with smtp (Exim 4.34) id 1E5N1v-0001s6-7T for vdr@linuxtv.org; Wed, 17 Aug 2005 14:28:27 +0200 Received: (qmail invoked by alias); 17 Aug 2005 12:27:56 -0000 Received: from p508AB1DB.dip0.t-ipconnect.de (EHLO [192.168.0.8]) [80.138.177.219] by mail.gmx.net (mp001) with SMTP; 17 Aug 2005 14:27:56 +0200 X-Authenticated: #3446302 From: Marcel Wiesweg To: Klaus Schmidinger's VDR Date: Wed, 17 Aug 2005 14:27:48 +0200 User-Agent: KMail/1.8.1 References: <4300CD1C.209@gmx.de> <200508161657.08329.marcel.wiesweg@gmx.de> <430220DC.6070709@gmx.de> In-Reply-To: <430220DC.6070709@gmx.de> MIME-Version: 1.0 Message-Id: <200508171427.48174.marcel.wiesweg@gmx.de> X-Y-GMX-Trusted: 0 Subject: [vdr] Re: Watchdog kicks in, 1.3.28, 1.3.29 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2005 12:28:27 -0000 Status: O X-Status: X-Keywords: X-UID: 4221 Am Dienstag 16 August 2005 19:22 schrieb Malte Schröder: > >>>I will try LD_ASSUME_KERNEL, let's see ... > >> > >>Seems to "fix" the problem .. so how can we debug this? > > > > See if the problem exists running under gdb as well. If it does, set a > > breakpoint to the watchdog function (maybe gdb catches SIGALRM before). > > When the watchdog expires, get a bt from all threads (thread apply all > > bt) and examine where the main thread is hanging. > > If the error does not occur, let VDR segfault in Watchdog() (something > > like (*((int *)0))++; will do this), and examine the core file (set > > ulimit -c unlimited) > > The backtrace is attached (thread 1 moved to top). The backtrace suggests something is wrong in DvbTuner: Either the poll() in thread 2 does not return, or there is some sort of deadlock. Unfortunately I cannot reproduce the problem here. First you might try if the attached patch fixes the problem. If not, please put printfs around Lock() and Unlock() in dvbtuner.c line 129, 138, 299, 339, and possibly around the poll in line 157 as well, such as printf("DvbTuner::Set: Now locking mutex\n"); Lock(); printf("DvbTuner::Set: Lockedmutex\n"); ... printf(""DvbTuner::Set: Unlocking mutex"); Unlock(); and capture the output to a file. Marcel > > > Marcel --- dvbdevice.c.orig 2005-08-17 13:32:50.000000000 +0200 +++ dvbdevice.c 2005-08-17 14:15:35.000000000 +0200 @@ -83,5 +83,5 @@ cMutex mutex; cCondVar locked; - cCondWait newSet; + cCondVar newSet; bool GetFrontendEvent(dvb_frontend_event &Event, int TimeoutMs = 0); bool SetFrontend(void); @@ -116,5 +116,6 @@ active = false; tunerStatus = tsIdle; - newSet.Signal(); + newSet.Broadcast(); + locked.Broadcast(); Cancel(3); } @@ -127,5 +128,6 @@ void cDvbTuner::Set(const cChannel *Channel, bool Tune, bool UseCa) { - Lock(); + //Lock(); + cMutexLock MutexLock(&mutex); if (Tune) tunerStatus = tsSet; @@ -136,10 +138,15 @@ startTime = time(NULL); channel = *Channel; - Unlock(); - newSet.Signal(); + //Unlock(); + //newSet.Signal(); + newSet.Broadcast(); } bool cDvbTuner::Locked(int TimeoutMs) { + bool isLocked = (tunerStatus >= tsLocked); + if (isLocked || !TimeoutMs) + return isLocked; + cMutexLock MutexLock(&mutex); if (TimeoutMs && tunerStatus < tsLocked) @@ -297,12 +304,19 @@ active = true; while (active) { - Lock(); - if (tunerStatus == tsSet) { - while (GetFrontendEvent(event)) - ; // discard stale events - tunerStatus = SetFrontend() ? tsTuned : tsIdle; - } - if (tunerStatus != tsIdle) { - while (GetFrontendEvent(event, 10)) { + bool hasEvent = GetFrontendEvent(event, 1); + + cMutexLock MutexLock(&mutex); + switch (tunerStatus) { + case tsIdle: + break; + case tsSet: + if (hasEvent) + continue; + tunerStatus = SetFrontend() ? tsTuned : tsIdle; + continue; + case tsTuned: + case tsLocked: + case tsCam: + if (hasEvent) { if (event.status & FE_REINIT) { tunerStatus = tsSet; @@ -310,10 +324,11 @@ } if (event.status & FE_HAS_LOCK) { - cMutexLock MutexLock(&mutex); tunerStatus = tsLocked; locked.Broadcast(); } + continue; } } + if (ciHandler) { if (ciHandler->Process() && useCa) { @@ -337,8 +352,8 @@ tunerStatus = tsLocked; } - Unlock(); // in the beginning we loop more often to let the CAM connection start up fast if (tunerStatus != tsTuned) - newSet.Wait((ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); + newSet.TimedWait(mutex, (ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); + } }