Re: [LOR] kqueue()

From: Craig Rodrigues <rodrigc_at_crodrigues.org>
Date: Sun, 17 Jul 2005 12:59:45 -0400
On Sun, Jul 17, 2005 at 11:39:36AM -0400, Craig Rodrigues wrote:
> On Sat, Jul 16, 2005 at 10:44:43PM +0000, Wojciech A. Koszek wrote:
> > http://FreeBSD.czest.pl/dunstan/kqueuetest.c
> 
> I can reproduce this LOR:
> 
> It looks like on line 1545 of kern_event.c, we have a KQ_LOCK(kq);,
> and then on line 1039, the KQ_NOTOWNED(kq); assertion fails, because
> the lock is never released.

Can you try this patch:

--- /usr/src/sys/kern/kern_event.c.orig	Sun Jul 17 12:32:58 2005
+++ /usr/src/sys/kern/kern_event.c	Sun Jul 17 12:41:54 2005
_at__at_ -410,7 +410,15 _at__at_
 		kev.fflags = kn->kn_sfflags;
 		kev.data = kn->kn_id;			/* parent */
 		kev.udata = kn->kn_kevent.udata;	/* preserve udata */
+
+		if (kn->kn_status & KN_HASKQLOCK)
+			KQ_UNLOCK(kn->kn_kq);
+
 		error = kqueue_register(kn->kn_kq, &kev, NULL, 0);
+
+		if (kn->kn_status & KN_HASKQLOCK)
+			KQ_LOCK(kn->kn_kq);
+
 		if (error)
 			kn->kn_fflags |= NOTE_TRACKERR;
 	}




I don't get the crash any more, but sometimes I get this LOR
in dmesg:

lock order reversal
 1st 0xc1b0aaa4 process lock (process lock) _at_ /usr/src/sys/kern/kern_fork.c:690
 2nd 0xc092dba0 allproc (allproc) _at_ /usr/src/sys/kern/kern_proc.c:229
KDB: stack backtrace:
kdb_backtrace(0,ffffffff,c0943620,c0943710,c08eb0ac) at kdb_backtrace+0x29
witness_checkorder(c092dba0,1,c087a870,e5) at witness_checkorder+0x564
_sx_slock(c092dba0,c087a870,e5,c18af2a8,c18af220) at _sx_slock+0x50
pfind(36c,c18af2a8,d15d4c50,c18af24c,d15d4c24) at pfind+0x1c
filt_procattach(c18af220,0,fffffffb,0,0) at filt_procattach+0x16
kqueue_register(c1b14900,d15d4c3c,0,0,36c) at kqueue_register+0x5c3
filt_proc(c18af2a8,4000036c) at filt_proc+0xcc
knote(c1b0abf0,4000036c,1,d15d4cc0,d15d4cb0) at knote+0x98
fork1(c18cec80,14,0,d15d4cd4,d15d4d30) at fork1+0xed4
fork(c18cec80,d15d4d04,0,a,246) at fork+0x18
syscall(3b,3b,3b,bfbfea00,14) at syscall+0x22f
Xint0x80_syscall() at Xint0x80_syscall+0x1f
Received on Sun Jul 17 2005 - 14:59:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:39 UTC