Subject: transcode on amd64 dumps core when running plugin
To: None <tech-pkg@netbsd.org, port-amd64@netbsd.org>
From: Rhialto <rhialto@falu.nl>
List: port-amd64
Date: 07/17/2005 16:46:47
I don't know very much about the workings of transcode, or dynamic
loading, so I thought I'd
post some info here.

Transcode seems to dump core after doing a lot of work correctly, and
then it wants to initialise a plugin when there is some weird argument
corruption.

Here is some output to show what happens.

$ transcode  -H 10 -z -k -o snapshot -y ppm,null -x vob,null -i /dev/dvdrw -c 16-17 -L 75751 -q 255
transcode v0.6.12 (C) 2001-2003 Thomas Oestreich, 2003-2004 T. Bitterberg
...
(dvd_reader.c) DVD title 1/11: 36 chapter(s), 1 angle(s), title set 1
(dvd_reader.c) title playback time: 01:35:59.20  5760 sec
(dvd_reader.c) [Chapter 01] 00:00:00.000 , block from 95 to 150247
(dvd_reader.c) [Chapter 02] 00:04:35.840 , block from 150248 to 152525
...
(dvd_reader.c) [Chapter 36] 01:33:04.760 , block from 1894117 to 1980430
[transcode] (probe) suggested AV correction -D 0 (0 ms) | AV 0 ms | 0 ms
code] auto-probing source /dev/dvdrw (ok)
[transcode] V: import format    | MPEG-2 DVD PAL (V=vob|A=null)
16 frames to 17 frames 
[transcode] V: AV demux/sync    | (1) sync AV at initial MPEG sequence
[transcode] V: import frame     | 720x576  1.25:1  encoded @ 16:9
[transcode] V: flip frame       | yes
[transcode] V: rgb2bgr          | yes
[transcode] V: bits/pixel       | 0.174
[transcode] V: decoding fps,frc | 25.000,3
[transcode] A: import format    | 0x2001  AC3/A52      [48000,16,2]
[transcode] A: export           | disabled
[transcode] V: encoding fps,frc | 25.000,3
[transcode] A: language         | en
[transcode] A: bytes per frame  | 7680 (7680.000000)
[transcode] A: adjustment       | 0@1000
[transcode] encoder delay = decode=40000 encode=40000 usec
[transcode] V: video buffer     | 10 @ 720x576
[transcode] allocating 10 framebuffer (static)
loading audio import module /usr/pkg/lib/transcode/import_null.so
loading video import module /usr/pkg/lib/transcode/import_vob.so
module=tca_import [option=20, flag=255]
Bus error (core dumped)


$ gdb /usr/pkg/bin/transcode transcode.core 
GNU gdb 5.3nb1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64--netbsd"...(no debugging symbols found)...
Core was generated by `transcode'.
Program terminated with signal 10, Bus error.
Reading symbols from /usr/libexec/ld.elf_so...(no debugging symbols found)...
done.
Loaded symbols for /usr/libexec/ld.elf_so
Reading symbols from /usr/lib/libm.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libm.so.0
Reading symbols from /usr/lib/libpthread.so.0...(no debugging symbols found)...
done.
Loaded symbols for /usr/lib/libpthread.so.0
Reading symbols from /usr/lib/libintl.so.0...(no debugging symbols found)...
done.
Loaded symbols for /usr/lib/libintl.so.0
Reading symbols from /usr/lib/libc.so.12...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libc.so.12
Reading symbols from /usr/pkg/lib/transcode/import_null.so...done.
Loaded symbols for /usr/pkg/lib/transcode/import_null.so
Reading symbols from /usr/pkg/lib/transcode/import_vob.so...done.
Loaded symbols for /usr/pkg/lib/transcode/import_vob.so
#0  tc_import (opt=20, para1=0x40f84cd000000000, para2=0x7f7fffffe7e0)
    at import_def.h:50
50          verbose_flag = param->flag;
(gdb) print param
No symbol "param" in current context.

Note that MOD_name is a static function that must have been inlined into 
tc_import().

(gdb) list
45      
46      MOD_name
47      {
48          static int display=0;
49          
50          verbose_flag = param->flag;
51          
52          // print module version only once
53          if(verbose_flag && (display++ == 0)) fprintf(stderr, "[%s] %s %s\n", MOD_NAME, MOD_VERSION, MOD_CODEC);
54      
(gdb) bt
#0  tc_import (opt=20, para1=0x40f84cd000000000, para2=0x7f7fffffe780)
    at import_def.h:50
#1  0x000000000041d75c in tca_import (opt=20, para1=0x7f7fffffe780, para2=0x0)
    at dl_loader.c:117
#2  0x000000000041aef4 in import_init (vob=0x73e000, 
    a_mod=0x7f7fffffe780 "\001", v_mod=0x7f7fffffee10 "vob") at decoder.c:203
#3  0x0000000000411b3f in transcoder (mode=20, vob=0x73e000) at transcode.c:564
#4  0x00000000004177dd in main (argc=-6272, argv=0x0) at transcode.c:3850

Note the difference in arguments between stack frame #0 and #1 - I think
they should just be the same, given that tca_import() calls
TCA_import(opt, para1, para2) (where TCA_import is actually a function
pointer, pointing to a module's tc_import() function).

Somehow opt is ok, para1 is some spurious extra value, and para2 is in
fact the correct value for para1 here:

(gdb) print *(transfer_t *)para2
$4 = {flag = 255, fd = 0x0, size = 0, buffer = 0x0, buffer2 = 0x0, 
  attributes = 0}

Any further ideas?

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert      -- You author it, and I'll reader it.
\X/ rhialto/at/xs4all.nl        -- Cetero censeo "authored" delendum esse.