[vdr] VDR 1.7 FreeBSD segfault when cutting recordings
Klaus Schmidinger
Klaus.Schmidinger at tvdr.de
Mon Mar 18 10:50:11 CET 2013
On 18.03.2013 10:10, Gerhard Brauer wrote:
> On Mon, Mar 18, 2013 at 09:13:02AM +0100, Klaus Schmidinger wrote:
>> On 18.03.2013 08:41, Gerhard Brauer wrote:
>>>
>>> The cutting process now works without segfaulting or unbehavior exit
>>> of the vdr process itself - but during cutting i got A LOT of "frame
>>> larger than buffer" x greater then 8 (8 is fix in all messages).
>>> -----------
>>> Mar 18 08:30:12 s01 vdr: [50364416] ERROR: frame larger than buffer (17392 > 8)
>>> Mar 18 08:30:12 s01 vdr: [50364416] ERROR: frame larger than buffer (17514 > 8)
>>> Mar 18 08:30:12 s01 vdr: [50364416] video cutting thread ended (pid=33513, tid=50364416)
>>> Mar 18 08:30:13 s01 vdr: [50361344] info: Schnitt beendet
>>> -----------
>>> The cutting ends now always normally.
>>
>> I guess the problem is that Juergen has allocated the buffers on the
>> heap, but did not change the places where the buffer size is determined
>> using sizeof(buffer) and sizeof(buffer2). If you replace these with
>> MAXFRAMESIZE it should work.
>
> Yes, this works fine. I've had to add this to Juergen's patch:
> ---------
> @@ -108,7 +119,7 @@
> CurrentFileNumber = FileNumber;
> }
> if (fromFile) {
> - int len = ReadFrame(fromFile, buffer, Length, sizeof(buffer));
> + int len = ReadFrame(fromFile, buffer, Length, MAXFRAMESIZE);
> if (len < 0) {
> error = "ReadFrame";
> break;
> @@ -193,7 +204,7 @@
> if (FileNumber != CurrentFileNumber)
> fromFile = fromFileName->SetOffset(FileNumber, FileOffset);
> if (fromFile) {
> - int len = ReadFrame(fromFile, buffer2, Length2, sizeof(buffer2));
> + int len = ReadFrame(fromFile, buffer2, Length2, MAXFRAMESIZE);
> if (len >= 0 && len == Length2)
> CheckForSeamlessStream = true;
> }
> ---------------
>
> First I'm (me.noob <g>!) tried it with sizeof(MAXFRAMESIZE), the
> result was not what i expected ;-)
> But i consulted K&R, both mean heap and stack were realy nice
> things... Hej, i'm a ruby guy, we have garbage collectors ;-)
>
> I think Juergen will make a "final patch", i don't know if above
> changes are well for all platforms, maybe a #ifdef __FreeBSD__ is
> needed.
> But for me: it works!
>
> Thanks for a wonderfull piece oft software!
>>
>> Klaus
>>
>
> Regards
> Gerhard
>
>>>> --- cutter.c.orig
>>>> +++ cutter.c
>>>> @@ -83,7 +83,18 @@ void cCuttingThread::Action(void)
>>>> int LastIFrame = 0;
>>>> toMarks.Add(0);
>>>> toMarks.Save();
>>>> +#ifdef __FreeBSD__
>>>> + // XXX save thread stack space
>>>> + uchar *buffer = MALLOC(uchar, MAXFRAMESIZE);
>>>> + uchar *buffer2 = MALLOC(uchar, MAXFRAMESIZE);
>>>> + if (buffer == NULL || buffer2 == NULL) {
>>>> + free(buffer);
>>>> + error = "malloc";
>>>> + return;
>>>> + }
>>>> +#else
>>>> uchar buffer[MAXFRAMESIZE], buffer2[MAXFRAMESIZE];
>>>> +#endif
>>>> int Length2;
>>>> bool CheckForSeamlessStream = false;
>>>> bool LastMark = false;
>>>> @@ -216,6 +227,10 @@ void cCuttingThread::Action(void)
>>>> }
>>>> }
>>>> Recordings.TouchUpdate();
>>>> +#ifdef __FreeBSD__
>>>> + free(buffer);
>>>> + free(buffer2);
>>>> +#endif
>>>> }
>>>> else
>>>> esyslog("no editing marks found!");
>>>> --- thread.c.orig
>>>> +++ thread.c
>>>> @@ -242,7 +242,7 @@ void cThread::SetPriority(int Priority)
>>>> void cThread::SetIOPriority(int Priority)
>>>> {
>>>> #ifdef __FreeBSD__
>>>> - esyslog("ERROR: syscall(SYS_ioprio_set ...) unsupported on FreeBSD");
>>>> + // esyslog("ERROR: syscall(SYS_ioprio_set ...) unsupported on FreeBSD");
>>>> #else
>>>> if (syscall(SYS_ioprio_set, 1, 0, (Priority & 0xff) | (2 << 13)) < 0) // best effort class
>>>> LOG_ERROR;
For completeness, here's the patch as it will go into the current developer version.
Klaus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vdr-1.7.41-cutterbuffers.diff
Type: text/x-patch
Size: 1954 bytes
Desc: not available
URL: <http://www.linuxtv.org/pipermail/vdr/attachments/20130318/5d5778b8/attachment.bin>
More information about the vdr
mailing list