From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 23 23:03:47 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B84CC16A4CE for ; Thu, 23 Dec 2004 23:03:47 +0000 (GMT) Received: from linux01.gwdg.de (linux01.gwdg.de [134.76.13.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id C101043D5A for ; Thu, 23 Dec 2004 23:03:46 +0000 (GMT) (envelope-from jengelh@linux01.gwdg.de) Received: from linux01.gwdg.de (localhost [127.0.0.1])iBNN3irg018393; Fri, 24 Dec 2004 00:03:45 +0100 Received: from localhost (jengelh@localhost)iBNN3g0e018351; Fri, 24 Dec 2004 00:03:43 +0100 Date: Fri, 24 Dec 2004 00:03:41 +0100 (MET) From: Jan Engelhardt To: Max Laier In-Reply-To: <200412232307.41735.max@love2party.net> Message-ID: References: <200412232307.41735.max@love2party.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-hackers@freebsd.org Subject: Re: Kernel crash w/o reason X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Dec 2004 23:03:47 -0000 >1) In kmi_fops.d_open(): >| if(!mtx_trylock(&Open_lock)) { return EBUSY; } >| return 0; > >this can not work. You cannot return to userland with a lock acquired. So? The full code also contains a uio_read() function. If I release the lock in uio_read(), no crash happens. It's just in uio_close(). Why can't I hold this lock, as it is possible with Linux? A mutex is basically just an atomic counter AFAIK, and if nobody releases it in-between, it is still held by the time we enter uio_close() - thus it could be unlocked without problems. In theory at least. What should I use instead? A semaphore? >2) If you report a problem, try to provide an error message. In this case a >crashdump/panic string. When you do kernel programming you should always run >in a debug kernel. To debug this specific problem WITNESS is helpful. I've tracked it a little and found out that it is mtx_unlock() which crashes, or more precisely, it is line td1 = turnstile_head(ts) in _mtx_unlock_sleep() -- ts == NULL! I have dug deep into &m->mtx_object and it looks like the TC list (in turnstile_lookup) is empty, but I do not know why. >4) Why on earth do you use gmake? What's wrong with bsd.*.mk? It's a whole lot >easier. Because non-BSD (read: Linux, MINGW/MSYS and Cygwin) do not ship BSD make. And of course, that I got to GNU make first and had few joy to learn another make syntax. Jan Engelhardt -- ENOSPC