From bn@mail.tellique.de  Sat Apr 15 12:29:46 2000
Return-Path: <bn@mail.tellique.de>
Received: from mail.tellique.de (big-gw.tellique.de [195.126.133.179])
	by hub.freebsd.org (Postfix) with ESMTP id 4B21937B5A7
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 15 Apr 2000 12:29:43 -0700 (PDT)
	(envelope-from bn@mail.tellique.de)
Received: (from bn@localhost)
	by mail.tellique.de (8.8.7/8.8.8) id VAA23075;
	Sat, 15 Apr 2000 21:29:37 +0200
Message-Id: <200004151929.VAA23075@mail.tellique.de>
Date: Sat, 15 Apr 100 21:29:37 +0200 (CEST)
From: Boris Nikolaus <bn@tellique.de>
Sender: bn@mail.tellique.de
To: FreeBSD-gnats-submit@freebsd.org
Subject: when printing through gs: panic: lockmgr: not exclusive lock holder

>Number:         18024
>Category:       kern
>Synopsis:       when printing through gs: panic: lockmgr: not exclusive lock ho
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Apr 15 12:30:01 PDT 2000
>Closed-Date:    Mon Jul 23 08:49:03 PDT 2001
>Last-Modified:  Mon Jul 23 08:50:05 PDT 2001
>Originator:     Boris Nikolaus
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
>Environment:

From dmesg(1):
    ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
    ppc0: Generic chipset (EPP/NIBBLE) in COMPATIBLE mode
    ppi0: <Parallel I/O> on ppbus0
    lpt0: <Printer> on ppbus0
    lpt0: Interrupt-driven port
    plip0: <PLIP network interface> on ppbus0

From config file:
    # Parallel-Port Bus
    device              ppc0    at isa? irq 7
    device              ppbus
    device              lpt
    device              ppi
    device              plip
    options             DEBUG_LOCKS     # Extra debugging code for locks
                                        # added to find the lockmgr panic

From /etc/printcap:
    lp|ps|HP-Destjet 500:\
        :sh:\
        :lp=/dev/lpt0:sd=/var/spool/output/lpd:lf=/var/log/lpd-errs:\
        :pl#64:of=/usr/local/libexec/lpd/magicfilter-lp:
    
/usr/local/libexec/lpd/magicfilter-lp: 
    #!/usr/bin/perl 
    
    # treat LF as CR+LF
    printf("\033&k2G") || exit 2;

    # read first two characters
    read(STDIN, $first, 2) || exit 2;
    
    if ($first eq "%!") {
        # it is postscript; use ghostscript to convert
        open(OUT, "|/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOu
tputFile=- -");
        select OUT;     
    }                  

    # print file to printer (or ghostscript)
    print $first;
    while (read(STDIN, $buf, 4096)) {
        print $buf;
    }   
    
    if ($first ne "%!") {
        print "\f"; 
    }
    
    exit 0;

>Description:
    
When printing a PostScript file, the kernel panics immediately after printing:
% lpr test.ps
%       
panic: lockmgr: pid 221, not exclusive lock holder 219 unlocking
Debugger("panic")
Stopped at       Debugger+0x35:  movb    $0,0xc02fc980
db> trace              
Debugger(c0290143) at Debugger+0x35
panic(c028f340,dd,c028f320,db,40080040) at panic+0x70
debuglockmgr(c327b838,6,0,c7a0a700,c0292ad0) at debuglockmgr+0x29c
brelse(c327b810,c0948b80,10,0,0) at brelse+0x5b7
PPBUS_WRITE(c094a800,2,2000,c7a0a700,c094a800) at PPBUS_WRITE+0x1e50
spec_vnoperate(c841ae20,c0ae9700,c841ae0c,c022f139,c841ae20) at spec_vnoperate+0
x6e4
ufs_itimes(...) at ufs_itimes+0x250a
ufs_vnoperatespec(...) at ufs_vnoperatespec+0x15
vn_close(...) at vn_close+0x40
debug_vn_lock(...) at debug_vnlock+0xb4
fdrop(...) at fdrop+0xb9
closef(...) at closef+0x9b
fdfree(...) at fdfree+0x30
exit1(...) at exit1+0x189
exit1(...) at exit1
syscall(2f,2f,2f,0,ffffffff) at syscall+0x176
Xint0x80_syscall() at Xint0x80_syscall+0x26
db> ps 
pid proc     addr     uid ppid pgrp flag   stat wmesg wchan cmd
221 c7a0a700 c8419000 1   1    219  006004 2                gs
211 ...                
db>

When converting the file by hand and printing the result, everything works
fine:
% gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 -sOutputFile=- - <test.ps >test.djet5
00
% lpr test.djet500
% [ no panic ]

I've no idea, why this works and the other panics.

>How-To-Repeat:

On my machine the crash occurs whenever I print a PostScript file.

I have no way to check if it occurs everywhere using my config or magicfilter
or ...

If you need further information (memory dumps after the panic or some config
parameters) don't hesitate to ask me: bn@tellique.de

>Fix:
   
You can get around this bug by converting the postscript file before
printing (s. a.).

>Release-Note:
>Audit-Trail:

From: andrew@ugh.net.au
To: freebsd-gnats-submit@FreeBSD.org, bn@tellique.de
Cc:  
Subject: Re: kern/18024: when printing through gs: panic: lockmgr: not exclusive lock ho
Date: Wed, 2 Aug 2000 00:52:47 +1000

 Just a "me to". At the time it was always reproducible although I'm not=
  sure if I can remeber how atm. I would get a panic on printing from a =
 mac (in ps format) via lpr.
 
 /etc/printcap contains:
 
 epson-bw|lp|Epson=
  Color Stylus 200 (B&W):\
         :sh:of=3D/usr/local/libexec/lpr/epson=
 _bw.sh:\
         :lp=3D/dev/lpt0:sd=3D/var/spool/lpd/epson-bw:lf=3D/var=
 /log/lpd-errs:
 
 epson_bw.sh just runs gs with a few arguments. There pa=
 nic message was:
 
 lockmgr: pid 130, not exclusive lock holder 116 unloc=
 king.
 
 The file system was usually pretty sick after this :-(
 
 Thanks,
 =
 
 Andrew
 
 
State-Changed-From-To: open->feedback 
State-Changed-By: mike 
State-Changed-When: Sat Jul 21 18:32:32 PDT 2001 
State-Changed-Why:  

Does this problem still occur in newer versions of FreeBSD, 
such as 4.3-RELEASE? 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18024 

From: Mike Barcroft <mike@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/18024: when printing through gs: panic: lockmgr: not exclusive lock ho
Date: Sat, 21 Jul 2001 22:39:58 -0400

 Adding to Audit-Trail.
 
 On Sat, Jul 21, 2001 at 10:13:42PM -0400, parv wrote:
 > on Jul 21 21:50, i got this from mike...
 > > Synopsis: when printing through gs: panic: lockmgr: not exclusive lock ho
 > > 
 > > State-Changed-From-To: open->feedback
 > > State-Changed-By: mike
 > > State-Changed-When: Sat Jul 21 18:32:32 PDT 2001
 > > State-Changed-Why: 
 > > 
 > > Does this problem still occur in newer versions of FreeBSD,
 > > such as 4.3-RELEASE?
 > > 
 > > http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18024
 > 
 > 
 > i am running 4.3-stable, don't know about -release.
 > 
 > i have printed postscript files from many programs, mainly from
 > enscript, w/o any problems directly (to lexmark optra e310).
 > 
 > -- 
 >  so, do you like word games or scrabble?
 > 	 - parv

From: Boris Nikolaus <bn@tellique.de>
To: mike@FreeBSD.org
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/18024: when printing through gs: panic: lockmgr: not exclusive lock ho
Date: Mon, 23 Jul 2001 04:12:22 +0200

 Hi Mike,
 
 The crash does not occur on 4.3-STABLE, but I cannot tell you about
 -RELEASE.
 
 I had examined the problem some time ago and found out that it always
 happened, when a process opens /dev/lpt0, forks a child, and then
 terminates before the child exits. Here's a simple perl program which
 caused the crash on earlier releases (kill lpr before starting it,
 otherwise /dev/lpt0 is busy):
 
 --- printercrash ---
 #!/usr/bin/perl
 
 # open printer device
 open(PRINTER, "/dev/lpt0") or die "Cannot open /dev/lpt0: $!";
 
 # fork() a child
 defined(my $pid = fork) or die "Cannot fork: $!";
 
 # parent process exit()s
 exit 0 if $pid;
 
 # child waits until the parent has exited
 while (getppid != 1) { sleep(1); }
 
 # now the child process exit()s
 exit 0;
 --- printercrash ---
 
 Sorry for sending this program so late, but after changing my
 printcap/magicfilter, I forgot about the problem ...
 
 Greetings,
 Boris
State-Changed-From-To: feedback->closed 
State-Changed-By: mike 
State-Changed-When: Mon Jul 23 08:49:03 PDT 2001 
State-Changed-Why:  

Originator confirmed this is no longer a problem in 4.3-STABLE. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=18024 
>Unformatted:
 lder
