[Fixed]Bug in libhb/dvdnav.c

Archive of historical bug reports.
Please use the GitHub link above to report issues.
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
Ptitboul
Posts: 4
Joined: Fri Jan 01, 2010 1:22 pm

[Fixed]Bug in libhb/dvdnav.c

Post by Ptitboul »

A few days ago I posted a bug report that was rejected because I only gave the relevant part of the Activity Log.
Therefore, I thought that it was better to provide more technical information on how to circumvent the bug.

There is a bug in libhb/dvdnav.c line 911, which is triggered by some DVDs, e.g. the second DVD of my edition of Lawrence of Arabia.
This line is part of a hack that tries to deal with some missing feature of libdvdnav, but the line does

Code: Select all

sector -= pgc_change->block_start
without checking that the result will be a positive value. And since

Code: Select all

sector
is an unsigned integer, the result with my DVD is that

Code: Select all

dvdnav_sector_search
(line 961) is called with a much too big argument.

A quick patch that works for my DVD is to add before line 911 the following check:

Code: Select all

if (sector >= pgc_change->block_start)
However, a better solution would be to replace lines 883 to 959 by a reliable way to circumvent the limitations of libdvdnav, or better, to improve libdvdnav.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Bug in libhb/dvdnav.c

Post by JohnAStebbins »

Hmm, that block of code doesn't really look right to me. It seems like it should be subtracting the length of each pgc in sectors as it crosses pgc's. Instead it is subtracting the block_start which is relative to the start of the VOB file set. I think it is making the assumption that the pgcs are all in sequential order in the VOB. This would usually be a good assumption since dvds are designed to play smoothly (minimal seeking). It also seems like there's an assumption that the first block_start will be 0. And it is modifying the sector value even when there is no pgc change detected. Unfortunately, I don't have the disc that prompted the original change. See http://forum.handbrake.fr/viewtopic.php ... sis#p55620
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Bug in libhb/dvdnav.c

Post by JohnAStebbins »

Ptiboul, if you're monitoring this, could you try a patch for me to see if it helps.
http://handbrake.fr/pastebin/pastebin.php?show=1178

This sums the sector sizes of each chapter as it is crossed instead of just subtracting the chapter start block of the first chapter of the pgc that the desired sector is found in. Since I don't have your source, I'm shooting in the dark. But I think this eliminates all the assumptions I noted in my previous post.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Bug in libhb/dvdnav.c

Post by JohnAStebbins »

BradleyS found a disc also affected by this. I validated that my patch fixed his problem and also still works on the disc that this code was originally put in place for (Genesis, The video show). So I've committed it to svn.
Ptitboul
Posts: 4
Joined: Fri Jan 01, 2010 1:22 pm

Re: Bug in libhb/dvdnav.c

Post by Ptitboul »

I don't really monitor this, as you can see.
I will try your patch when I get the DVD back...
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Bug in libhb/dvdnav.c

Post by JohnAStebbins »

FYI, The latest snapshot includes the patch.
kogyaru
Posts: 25
Joined: Sat Apr 14, 2007 1:29 am

Re: Bug in libhb/dvdnav.c

Post by kogyaru »

What are the symptoms of this bug? Given that I cannot find the original author's first and rejected post, and cannot tell what the reported symptoms of the bug are, I wonder if the bug is related to what I'm experiencing with dvdnav (0.9.4 and r3154): it makes HB hangs every time on a certain track when scanning the entire DVD. dvdread, however, works fine with the DVD and scans it in its entirety.
User avatar
JohnAStebbins
HandBrake Team
Posts: 5726
Joined: Sat Feb 09, 2008 7:21 pm

Re: Bug in libhb/dvdnav.c

Post by JohnAStebbins »

This problem results in seek failures and error messages that you would see in the log. It won't result in a hang.
Post Reply