From dougb@FreeBSD.org  Wed Nov 18 01:13:27 2009
Return-Path: <dougb@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E87971065713
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Nov 2009 01:13:27 +0000 (UTC)
	(envelope-from dougb@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28])
	by mx1.freebsd.org (Postfix) with ESMTP id BE2B48FC18;
	Wed, 18 Nov 2009 01:13:27 +0000 (UTC)
Received: from freefall.freebsd.org (localhost [127.0.0.1])
	by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nAI1DR4M027360;
	Wed, 18 Nov 2009 01:13:27 GMT
	(envelope-from dougb@freefall.freebsd.org)
Received: (from dougb@localhost)
	by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nAI1DRuT027359;
	Wed, 18 Nov 2009 01:13:27 GMT
	(envelope-from dougb)
Message-Id: <200911180113.nAI1DRuT027359@freefall.freebsd.org>
Date: Wed, 18 Nov 2009 01:13:27 GMT
From: Doug Barton <dougb@freebsd.org>
Reply-To: Doug Barton <dougb@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: "Joseph S. Atkinson" <jsa.bsd@gmail.com>
Subject: multimedia/vlc causes a panic if media files are on msdosfs
X-Send-Pr-Version: 3.113
X-GNATS-Notify: jsa@wickedmachine.net

>Number:         140648
>Category:       kern
>Synopsis:       multimedia/vlc causes a panic if media files are on msdosfs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kib
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Nov 18 01:20:01 UTC 2009
>Closed-Date:    Fri Nov 20 22:52:56 UTC 2009
>Last-Modified:  Sat Nov 21 01:40:00 UTC 2009
>Originator:     Doug Barton
>Release:        FreeBSD 8.0-RC1 i386
>Organization:
AAAG
>Environment:
9-current as of r199418, vlc 1.0.3_1, with data on an msdosfs partition.
>Description:
When I try to access multimedia files on an msdosfs partition the kernel
panics. Accessing the same files on the command line, with another client
(mplayer), or from a UFS partition does not cause any problems. 

Panic is as follows:

(kgdb) #0  doadump () at pcpu.h:246
#1  0xc05f5a2f in boot (howto=260)
    at /usr/local/src/sys/kern/kern_shutdown.c:416
#2  0xc05f5d12 in panic (fmt=Variable "fmt" is not available.
) at /usr/local/src/sys/kern/kern_shutdown.c:579
#3  0xc05e61c7 in _mtx_assert (m=0xc0982cf0, what=4, 
    file=0xc08d1a5c "/usr/local/src/sys/kern/kern_mutex.c", line=223)
    at /usr/local/src/sys/kern/kern_mutex.c:708
#4  0xc05e6846 in _mtx_unlock_flags (m=0xc0982cf0, opts=0, 
    file=0xc08cdbf7 "/usr/local/src/sys/kern/kern_descrip.c", line=737)
    at /usr/local/src/sys/kern/kern_mutex.c:223
#5  0xc05c22f3 in kern_fcntl (td=0xc62ac000, fd=10, cmd=16, arg=131072)
    at /usr/local/src/sys/kern/kern_descrip.c:737
#6  0xc05c2691 in fcntl (td=0xc62ac000, uap=0xea5b3cf8)
    at /usr/local/src/sys/kern/kern_descrip.c:385
#7  0xc0863bc3 in syscall (frame=0xea5b3d38)
    at /usr/local/src/sys/i386/i386/trap.c:1078
#8  0xc0847110 in Xint0x80_syscall ()
    at /usr/local/src/sys/i386/i386/exception.s:261
#9  0x00000033 in ?? ()
Previous frame inner to this frame (corrupt stack?)


>How-To-Repeat:
See above.
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->dougb 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Nov 18 01:20:11 UTC 2009 
Responsible-Changed-Why:  
Submitter has GNATS access (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140648 
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Wed Nov 18 01:20:15 UTC 2009 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140648 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: jsa@wickedmachine.net
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/140648: multimedia/vlc causes a panic if media files are on msdosfs
Date: Wed, 18 Nov 2009 01:20:13 UT

 Maintainer of multimedia/vlc,
 
 Please note that PR ports/140648 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/140648
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: "Joseph S. Atkinson" <jsa.bsd@gmail.com>
To: bug-followup@FreeBSD.org, dougb@freebsd.org
Cc:  
Subject: Re: ports/140648: multimedia/vlc causes a panic if media files are
 on msdosfs
Date: Tue, 17 Nov 2009 20:39:48 -0500

 Acknowledged.
 
 I have already fired of an email to upstream hoping that this can be duplicated 
 on his 8 machine. Will test it on a fbsd8 machine myself with an msdosfs usb 
 stick a little later as well.
 
 I can confirm and duplicate this problem. I can trigger it with vlc reading 
 ntfs. Tested with totem and it did not happen.

From: =?ISO-8859-1?Q?Rafa=EBl_Carr=E9?= <rafael.carre@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/140648: multimedia/vlc causes a panic if media files are
 on msdosfs
Date: Thu, 19 Nov 2009 00:16:35 +0100

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enig2EE1AAFDE2BE7E93E594D2F0
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 #3 0xc05e61c7 in _mtx_assert (m=3D0xc0982cf0, what=3D4,
 
 What is the assertion ?
 
 #7 0xc0863bc3 in syscall (frame=3D0xea5b3d38)
 =2E..
 #9 0x00000033 in ?? ()
 Previous frame inner to this frame (corrupt stack?)
 
 0xea... doesn't look like a valid pointer, all other addresses start
 with 0xc0..., perhaps there is memory corruption in VLC. I don't know
 how to detect this since valgrind doesn't run on FreeBSD.
 
 I don't know why else the backtrace inside VLC wouldn't be shown.
 
 Is the panic systematic ?
 
 (Note, Joseph Atkinson tried vlc --file-mmap & --no-file-mmap without
 results)
 
 Perhaps truss vlc would tell what is the last function called from VLC
 if its output can be logged while FreeBSD panics?
 
 --=20
 Rafa=EBl Carr=E9
 
 
 --------------enig2EE1AAFDE2BE7E93E594D2F0
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG/MacGPG2 v2.0.12 (Darwin)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
 
 iEYEARECAAYFAksEgFYACgkQYWCeGMCv8Q/+yQCfU3z/H9ol8EmOUQGkQmvzkiaH
 XIgAoNX1WeJszv96rwGKOv1PqiaBwmsK
 =7Q4t
 -----END PGP SIGNATURE-----
 
 --------------enig2EE1AAFDE2BE7E93E594D2F0--

From: Doug Barton <dougb@FreeBSD.org>
To: Kostik Belousov <kostikbel@gmail.com>
Cc: freebsd-current@freebsd.org, delphij@freebsd.org, 
 bug-followup@freebsd.org
Subject: Re: ports/140648 multimedia/vlc causes a panic if media files are
 on msdosfs
Date: Fri, 20 Nov 2009 13:55:16 -0800

 Kostik Belousov wrote:
 > On Thu, Nov 19, 2009 at 02:30:33PM -0800, Doug Barton wrote:
 >> Please see http://www.freebsd.org/cgi/query-pr.cgi?pr=140648 for more
 >> information, including a trace.
 >>
 >> There is also some evidence that the same problem is triggered by
 >> accessing files on an NTFS partition. The VLC folks have suggested
 >> that the problem may be related to threading.
 > 
 > This is because msdosfs and ntfs are not mpsafe, and it seems that
 > VLC using recently added F_RDAHEAD/F_READAHEAD fcntls.
 > 
 > Please try this.
 > 
 > diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
 > index 434f54a..676de65 100644
 > --- a/sys/kern/kern_descrip.c
 > +++ b/sys/kern/kern_descrip.c
 > @@ -718,14 +718,15 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
 >  			do {
 >  				new = old = fp->f_flag;
 >  				new |= FRDAHEAD;
 > -			} while (atomic_cmpset_rel_int(&fp->f_flag, old, new) == 0);
 > +			} while (!atomic_cmpset_rel_int(&fp->f_flag, old, new));
 >  readahead_vnlock_fail:
 >  			VFS_UNLOCK_GIANT(vfslocked);
 > +			vfslocked = 0;
 >  		} else {
 >  			do {
 >  				new = old = fp->f_flag;
 >  				new &= ~FRDAHEAD;
 > -			} while (atomic_cmpset_rel_int(&fp->f_flag, old, new) == 0);
 > +			} while (!atomic_cmpset_rel_int(&fp->f_flag, old, new));
 >  		}
 >  		fdrop(fp, td);
 >  		break;
 
 Voila! Thanks.
 
 Doug
 
 -- 
 
 	Improve the effectiveness of your Internet presence with
 	a domain name makeover!    http://SupersetSolutions.com/
 
Responsible-Changed-From-To: dougb->kib 
Responsible-Changed-By: kib 
Responsible-Changed-When: Fri Nov 20 22:10:21 UTC 2009 
Responsible-Changed-Why:  
I have a patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140648 
State-Changed-From-To: feedback->closed 
State-Changed-By: kib 
State-Changed-When: Fri Nov 20 22:52:13 UTC 2009 
State-Changed-Why:  
Patch committed, r199617. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=140648 

From: Doug Barton <dougb@FreeBSD.org>
To: kib@FreeBSD.org
Cc: jsa@wickedmachine.net, bug-followup@FreeBSD.org
Subject: Re: kern/140648: multimedia/vlc causes a panic if media files are
 on msdosfs
Date: Fri, 20 Nov 2009 17:31:53 -0800

 kib@FreeBSD.org wrote:
 > Synopsis: multimedia/vlc causes a panic if media files are on msdosfs
 > 
 > State-Changed-From-To: feedback->closed
 > State-Changed-By: kib
 > State-Changed-When: Fri Nov 20 22:52:13 UTC 2009
 > State-Changed-Why: 
 > Patch committed, r199617.
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=140648
 
 There were reports that this bug was also seen in RELENG_8, would this
 patch apply there as well?
 
 
 Doug
 
 -- 
 
 	Improve the effectiveness of your Internet presence with
 	a domain name makeover!    http://SupersetSolutions.com/
 
>Unformatted:
