From owner-freebsd-bugs@freebsd.org Tue Nov 17 16:27:39 2015 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5BEE9A316F7 for ; Tue, 17 Nov 2015 16:27:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 409BA1F66 for ; Tue, 17 Nov 2015 16:27:39 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id tAHGRdQQ030919 for ; Tue, 17 Nov 2015 16:27:39 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 204633] If INVARIANTS is enabled, free() may attempt to acquire sleeping lock Date: Tue, 17 Nov 2015 16:27:39 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: jtl@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Nov 2015 16:27:39 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204633 Bug ID: 204633 Summary: If INVARIANTS is enabled, free() may attempt to acquire sleeping lock Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: jtl@freebsd.org While testing new code with WITNESS enabled, I saw this panic: panic: acquiring blockable sleep lock with spinlock or critical section held (sleep mutex) 64 Bucket @ /usr/src/sys/vm/uma_dbg.c:217 cpuid = 0 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe000021c690 vpanic() at vpanic+0x182/frame 0xfffffe000021c710 kassert_panic() at kassert_panic+0x126/frame 0xfffffe000021c780 witness_checkorder() at witness_checkorder+0x13b/frame 0xfffffe000021c800 __mtx_lock_flags() at __mtx_lock_flags+0xa4/frame 0xfffffe000021c850 uma_dbg_getslab() at uma_dbg_getslab+0x42/frame 0xfffffe000021c880 uma_dbg_alloc() at uma_dbg_alloc+0x36/frame 0xfffffe000021c8b0 uma_zalloc_arg() at uma_zalloc_arg+0x53e/frame 0xfffffe000021c910 bucket_alloc() at bucket_alloc+0xa6/frame 0xfffffe000021c930 uma_zfree_arg() at uma_zfree_arg+0x293/frame 0xfffffe000021c980 free() at free+0x8b/frame 0xfffffe000021c9c0 pmc_hook_handler() at pmc_hook_handler+0xbbb/frame 0xfffffe000021ca50 thread_exit() at thread_exit+0x1b7/frame 0xfffffe000021ca90 kern_thr_exit() at kern_thr_exit+0x119/frame 0xfffffe000021cac0 sys_thr_exit() at sys_thr_exit+0x62/frame 0xfffffe000021cae0 amd64_syscall() at amd64_syscall+0x2de/frame 0xfffffe000021cbf0 Xfast_syscall() at Xfast_syscall+0xfb/frame 0xfffffe000021cbf0 --- syscall (431, FreeBSD ELF64, sys_thr_exit), rip = 0x40b70a, rsp = 0x7fffde9f2ee8, rbp = 0x7fffde9f2f00 --- KDB: enter: panic The free() man page promises that free() will not sleep. However, if INVARIANTS is enabled, free() may very well attempt to acquire a sleeping lock. In fact, it appears that malloc() may even attempt to acquire a sleeping lock if INVARIANTS is enabled. The problem is that uma_zalloc_arg() calls uma_dbg_alloc(). uma_dbg_alloc() calls uma_dbg_getslab(). uma_dbg_getslab() may acquire the zone lock, which is a normal (sleepable) mutex. -- You are receiving this mail because: You are the assignee for the bug.