[vlc-devel] commit: utf8_open: make third parameter optional ( Rémi Denis-Courmont )

Rafaël Carré rafael.carre at gmail.com
Tue Aug 18 05:52:14 CEST 2009


On Sat, 15 Aug 2009 20:26:01 +0200 (CEST)
git at videolan.org (git version control) wrote:

> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat
> Aug 15 21:21:44 2009 +0300|
> [aee0317592c43b4fa6d9d84bc2e70968e4b93f5f] | committer: Rémi
> Denis-Courmont 
> 
> utf8_open: make third parameter optional

> -int utf8_open (const char *filename, int flags, mode_t mode)
> +int utf8_open (const char *filename, int flags, ...)
>  {
> +    mode_t mode = 0;
> +    va_list ap;
> +
> +    va_start (ap, flags);
> +    if (flags & O_CREAT)
> +        mode = va_arg (ap, mode_t);
> +    va_end (ap);
> +

This breaks (SIGILL) on windows XP 32 bits as reported by Trax, my FreeBSD 8 (64 bits), OSX (jones); but not on Linux (i used valgrind/memcheck to catch anything obvious)

I didn't bisect to this commit but it looks like an evidence, although i can't tell what's going wrong there.


On FreeBSD, gdb will tell me the last line executed is the closing '}' of utf8_open(), and in the following backtrace, eip points to the 
instruction immediately following the call to utf8_open(), inside utf8_fopen().


Perhaps it has something to do with how return values are stored on the stack on x86/x86_64 and how va_* (__builtin_va_*?) macro messes with the stack.


5:21 videolan at jones ~/funman/vlc/test% gdb ./test_libvlc_core /cores/core.21927
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40 UTC 2008)

Core was generated by `./test_libvlc_core'.

#0  utf8_open (filename=0xbffff730 "/Users/videolan/Library/Caches/VLC/CACHEDIR.TAG", flags=1537) at text/filesystem.c:99
99	        mode = va_arg (ap, mode_t);
(gdb) bt full

#0  utf8_open (filename=0xbffff730 "/Users/videolan/Library/Caches/VLC/CACHEDIR.TAG", flags=1537) at text/filesystem.c:99
	ap = 0xbffff6e8 "�\001"
	local_name = <value temporarily unavailable, due to optimizations>
	fd = <value temporarily unavailable, due to optimizations>

#1  0x0018128d in utf8_fopen (filename=0xbffff6e8 "�\001", mode=0x1c7070 "wb") at text/filesystem.c:185
	rwflags = <value temporarily unavailable, due to optimizations>
	oflags = 1536
	append = false
	fd = -1073744152
	stream = (FILE *) 0x0

#2  0x001882e2 in CacheSave (p_this=0x806aa8, p_bank=0x305100) at modules/cache.c:495
	psz_tag = "Signature: 8a477f597d28d172789f06886806bc55\r\n# This file is a cache directory tag created by VLC.\r\n# For information about cache directory tags, see:\r\n#   http://www.brynosaurus.com/cachedir/\r\n"
	psz_cachedir = 0x36b270 "/Users/videolan/Library/Caches/VLC"
	file = (FILE *) 0xbffff6e8
	i = <value temporarily unavailable, due to optimizations>
	j = <value temporarily unavailable, due to optimizations>
	i_cache = <value temporarily unavailable, due to optimizations>
	pp_cache = <value temporarily unavailable, due to optimizations>
	i_file_size = 0

#3 0x00187625 in module_EndBank (p_this=0x806aa8, b_plugins=true) at modules/modules.c:189
	p_bank = (module_bank_t *) 0x305100
	__func__ = "module_EndBank"

#4  0x0010ab38 in libvlc_InternalCleanup (p_libvlc=0x806aa8) at libvlc.c:1083
	p_playlist = (playlist_t *) 0x430a378
	psz_pidfile = 0x430a378 "��?"

#5  0x0002969c in libvlc_release (p_instance=0x301740) at control/core.c:176
	lock = (vlc_mutex_t *) 0x301758
	__func__ = "libvlc_release"

#6  0x00004f35 in main () at libvlc/core.c:39
	vlc = (libvlc_instance_t *) 0x0
	argc = 0
	argv = (const char **) 0x0


(gdb) print mode
$1 = <variable optimized away by compiler>


(gdb) frame 1
#1  0x0018128d in utf8_fopen (filename=0xbffff6e8 "�\001", mode=0x1c7070 "wb") at text/filesystem.c:185
185	    int fd = utf8_open (filename, rwflags | oflags, 0666);




(gdb) disassemble $pc-32 $pc+32
Dump of assembler code from 0x18126d to 0x1812ad:
0x0018126d <utf8_fopen+109>:	add    %al,(%eax)
0x0018126f <utf8_fopen+111>:	add    %cl,-0x380df636(%ecx)
0x00181275 <utf8_fopen+117>:	inc    %esp
0x00181276 <utf8_fopen+118>:	and    $0x8,%al
0x00181278 <utf8_fopen+120>:	mov    $0x1,%dh
0x0018127a <utf8_fopen+122>:	add    %al,(%eax)
0x0018127c <utf8_fopen+124>:	xor    %edi,%edi
0x0018127e <utf8_fopen+126>:	mov    %edx,0x4(%esp)
0x00181282 <utf8_fopen+130>:	mov    0x8(%ebp),%eax
0x00181285 <utf8_fopen+133>:	mov    %eax,(%esp)
0x00181288 <utf8_fopen+136>:	call   0x181160 <utf8_open>
0x0018128d <utf8_fopen+141>:	cmp    $0xffffffff,%eax
0x00181290 <utf8_fopen+144>:	mov    %eax,%esi
0x00181292 <utf8_fopen+146>:	je     0x1812af <utf8_fopen+175>
0x00181294 <utf8_fopen+148>:	cmpb   $0x0,-0x9(%ebp)
0x00181298 <utf8_fopen+152>:	jne    0x1812c7 <utf8_fopen+199>
0x0018129a <utf8_fopen+154>:	mov    0xc(%ebp),%eax
0x0018129d <utf8_fopen+157>:	mov    %esi,(%esp)
0x001812a0 <utf8_fopen+160>:	mov    %eax,0x4(%esp)
0x001812a4 <utf8_fopen+164>:	call   0x1d9198 <dyld_stub_fdopen>
0x001812a9 <utf8_fopen+169>:	test   %eax,%eax
0x001812ab <utf8_fopen+171>:	mov    %eax,%edi
End of assembler dump.


(gdb) info registers 
eax            0xbffff6e8	-1073744152
ecx            0x1	1
edx            0x601	1537
ebx            0x18825b	1606235
esp            0xbffff6e0	0xbffff6e0
ebp            0xbffff708	0xbffff708
esi            0x600	1536
edi            0x0	0
eip            0x18128d	0x18128d <utf8_fopen+141>
eflags         0x210206	2163206
cs             0x17	23
ss             0x1f	31
ds             0x1f	31
es             0x1f	31
fs             0x0	0
gs             0x37	55
(gdb)  


-- 
Rafaël Carré
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20090818/5712f48b/attachment.sig>


More information about the vlc-devel mailing list