NetBSD Problem Report #42848

From www@NetBSD.org  Fri Feb 19 20:37:47 2010
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 1833663C470
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 19 Feb 2010 20:37:47 +0000 (UTC)
Message-Id: <20100219203746.DAEF363C142@www.NetBSD.org>
Date: Fri, 19 Feb 2010 20:37:46 +0000 (UTC)
From: lugarbleiz@gmail.com
Reply-To: lugarbleiz@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Kernel Panic while opening ttyU? or dtyU? with open() C function
X-Send-Pr-Version: www-1.0

>Number:         42848
>Category:       kern
>Synopsis:       Kernel Panic while opening ttyU? or dtyU? with open() C function
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 19 20:40:00 +0000 2010
>Closed-Date:    Sun May 04 22:19:50 +0000 2014
>Last-Modified:  Sun May 04 22:20:01 +0000 2014
>Originator:     Thomas Nivelet
>Release:        NetBSD-current (2nd february 2010)
>Organization:
>Environment:
NetBSD  5.99.24 NetBSD 5.99.24 (GENERIC) #0: Tue Feb  2 10:36:02 UTC 2010  builds@b7.netbsd.org:/home/builds/ab/HEAD/i386/201002020000Z-obj/home/builds/ab/HEAD/src/sys/arch/i386/compile/GENERIC i386
>Description:
when trying to open ttyU? with the C function like this:
open(fd, tty, O_RDONLY); with tty as an existing ttyU? it can't open the first ttyU and wait for it to be ready even if a umodem is connected to the system and crash if the umodem is disconnected while it's wait
with it's non-blocking version (dtyU?) it crash even if the device is still connected.

usb_transfer_complete(c1f79700,16e0,10,a,cb166f80,c1f6b640,0,c1f79700,c2012280,0)
at netbsd:usb_transfer_complete+0x3f
uhci_idone(c1f79754,16b4,4,a,8,28000000,cbad9000,c1f7977c,0,cbb226e0)
at netbsd:uhci_idone+0xb6
uhci_softintr(cbad9004,0,0,0,0,0,1000000,3,0,0) at netbsd:uhci_softintr+0x1af
softint_dispatch(cb16ec80,4,ffffffff,dfffffff,0,20000000,cb591d90,cb591d28,cb16ea00,0)
at netbsd:softint_dispatch+0x70
DDB lost frame for netbsd:Xsoftintr+0x3b, trying 0xcb591d88
Xsoftintr() at netbsd:Xsoftintr+0x3b
fatal page fault i supervisor mode
trap type 6 code 0 eip c02454e0 cs 8 eflags 10246 cr 2 ffffffff ilevel 8
kernel: supervisor trap page fault, code=0
faulted in DDB; continuing...
>How-To-Repeat:
just make a test application which open a ttyU? or a dtyU?, with the C function open(), compile, connect a umodem device and launch the application. if the ttyU has been chosen, disconnect the device while the software is still running.

Jeremy C. Reed asked me to test if it crash on NetBSD 5.0.2 before sending this PR, and unfortunately it crash on it too.

here is my own faulty code (in c++):

  while ((dirp = readdir(dp)) != NULL)
    {
      file = std::string(dirp->d_name);
      if (file.find("ttyU") != std::string::npos)
        {
          file = "/dev/" + file;
          devicefd = open(file.c_str(), O_RDONLY);
          if (devicefd != -1)
              if (ioctl(devicefd, USB_GET_DEVICE_DESC, &udd) != -1)
                std::cout << "there is " << static_cast<int>(udd.bNumConfigurations) << " configuration o
n this device" << std::endl;
        }
    }

>Fix:

>Release-Note:

>Audit-Trail:
From: "Jonathan A. Kollasch" <jakllsch@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42848 CVS commit: src/sys/dev/usb
Date: Sat, 14 Jan 2012 20:51:00 +0000

 Module Name:	src
 Committed By:	jakllsch
 Date:		Sat Jan 14 20:51:00 UTC 2012

 Modified Files:
 	src/sys/dev/usb: ucom.c

 Log Message:
 Stopgap XXX kludge for PR kern/42848 and PR kern/45013.

 Someone should really find and fix the real problem,
 but it's better to not crash in the meantime.


 To generate a diff of this commit:
 cvs rdiff -u -r1.95 -r1.96 src/sys/dev/usb/ucom.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: christos@NetBSD.org
State-Changed-When: Sun, 04 May 2014 18:19:50 -0400
State-Changed-Why:
Cannot reproduce anymore, please reopen with instructions how to reproduce
if this is still a problem.


From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42848 CVS commit: src/sys/dev/usb
Date: Sun, 4 May 2014 18:18:38 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Sun May  4 22:18:38 UTC 2014

 Modified Files:
 	src/sys/dev/usb: ucom.c

 Log Message:
 remove hack for PR/42848


 To generate a diff of this commit:
 cvs rdiff -u -r1.103 -r1.104 src/sys/dev/usb/ucom.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.