#24 bug in rgb.c

open
nobody
None
5
2002-01-02
2002-01-02
Anonymous
No

Hi,
I've been using extensively your package libdv together
with
others and found a weird bug on some of my AVI files.

I use raw AVI dv2 format files grabbed by dvgrab and
transform them into mjpeg stream using dv2jpg. A few
times I
got the following segmentation fault in grb.c file
(from libdv)

Starting
program: /scratch1/valya/tmp/dv2jpg-1.1/dv2jpg
/export/1/opt/DV/mik2001.08.11_16-24-08.avi p.mjpeg
reading /export/1/opt/DV/mik2001.08.11_16-24-08.avi
Compressor: WHAT
fps: 29.970629
video_frames: 684
video_strn: 0
audio_bytes: 4381992
audio_strn: 1
width: 720
height: 480
a_fmt: 1
a_chans: 2
a_rate: 48000
a_bits: 16
Video setup: width=352, height=240, fps=29.970629
audio setup: channels=2, rate=48000, bits=16, format=1
Copying 684 frames
frame 85
Program received signal SIGSEGV, Segmentation fault.
dv_mb411_rgb (mb=0x8063c58, pixels=0xbfffdc80,
pitches=0xbfffdc70)
at rgb.c:149
149 *pwrgb++ = rgblut[r];
(gdb) where
#0 dv_mb411_rgb (mb=0x8063c58, pixels=0xbfffdc80,
pitches=0xbfffdc70)
at rgb.c:149
#1 0x8052cb1 in dv_decode_full_frame (dv=0x8be0e90,
buffer=0x8069540 "\037\a",
color_space=e_dv_color_rgb, pixels=0xbfffdc80,
pitches=0xbfffdc70)
at dv.c:220
#2 0x804b4f0 in main (ac=3, av=0xbffff574) at
dv2jpg.c:139
#3 0x40328177 in ?? ()
(gdb) p pixels
$1 = (guchar **) 0xffecec91
(gdb) p *pixels
Cannot access memory at address 0xffecec91
(gdb) p **pixels
Cannot access memory at address 0xffecec91
(gdb) p pitches
$2 = (gint *) 0xbfffdc70
(gdb) p pixels
$3 = (guchar **) 0xffecec91
(gdb) p pixels[0]
Cannot access memory at address 0xffecec91
(gdb) p mb
$4 = (dv_macroblock_t *) 0xb3b2b1b0
I don't have a clue what is that, but think you can
help. In the case if you need input file it can be
downloaded from
http://www-clued0.fnal.gov/~vkuznet/BUGS/mik2001.08.11_16-24-08.avi
as well as dv2jpg executable (with debug option
enabled):
http://www-clued0.fnal.gov/~vkuznet/BUGS/dv2jpg

Thanks,
Valentin.

Discussion

  • Nobody/Anonymous

    Logged In: NO

    Make sure you are calling dv_init() at the start of your
    program somewhere. Without this, some functions in rgb.c
    will not have certain globally defined tables initialized,
    and it will crash. I had a very similar crashing problem
    until I tracked this down.

     
  • Nobody/Anonymous

    Logged In: NO

    Hi,
    glad to get feedback from the team developing libdv.
    Actually I check that the program I used (dv2jpg)
    contains call dv_init() which you suggested.
    Any further ideas?
    Many thanks for devloping this great product.

     
  • Nobody/Anonymous

    Logged In: NO

    Make sure you are calling dv_init() at the start of your
    program somewhere. Without this, some functions in rgb.c
    will not have certain globally defined tables initialized,
    and it will crash. I had a very similar crashing problem
    until I tracked this down.

     
  • kk kll

    kk kll - 2002-04-04

    Logged In: YES
    user_id=182868

    Hi,

    I encountered an almost identical problem. I had libdv
    crashing on a large (12 GB) raw dv file, got from dvgrab.
    Apparently it always works on small files, but there
    shouldn't be any connection.
    Initially libdv crashed somewhere in vlc_x86.S. It's been
    reported before - see request 452411. I didn't dare to check
    that code so I recompiled the library after a "./configure
    --disable-asm".
    The crash migrated to rgb.c, in function dv_mb420_rgb,
    line 256:

    gint32 r = (y + ro) >> COLOR_FRACTION_BITS;
    gint32 g = (y - go) >> COLOR_FRACTION_BITS;
    gint32 b = (y + bo) >> COLOR_FRACTION_BITS;
    *pwrgb0++ = rgblut[r]; <======= here =========
    *pwrgb0++ = rgblut[g];
    *pwrgb0++ = rgblut[b];

    The values of "y" and "r" are completely wild: -2021227132
    and -1973772, respectively.

    I used a dirty trick to correct the problem, something
    like this:
    gint32 r = ((y + ro) >> COLOR_FRACTION_BITS) & 1023;
    gint32 g = ((y - go) >> COLOR_FRACTION_BITS) & 1023;
    gint32 b = ((y + bo) >> COLOR_FRACTION_BITS) & 1023;

    Now it works, but maybe someone with more knowledge and
    time to spare should do it the proper way.

    Mihai

     
  • Stefan Lucke

    Stefan Lucke - 2002-05-23

    Logged In: YES
    user_id=38475

    Can you check your problems with lastest CVS version.
    I won't download 82MB !