Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 10 Apr 2011 18:18:47 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Fabian Keil <freebsd-listen@fabiankeil.de>
Cc:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: panic: _mtx_lock_sleep: recursed on non-recursive mutex process lock @ /usr/src/sys/kern/kern_exit.c:912
Message-ID:  <20110410151847.GT78089@deviant.kiev.zoral.com.ua>
In-Reply-To: <20110410153759.025aa4e2@fabiankeil.de>
References:  <20110410153759.025aa4e2@fabiankeil.de>

next in thread | previous in thread | raw e-mail | index | archive | help

--KEQY95CNCHRmtrVV
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Apr 10, 2011 at 03:37:59PM +0200, Fabian Keil wrote:
> The following panic seems to be reliably reproducible with sources
> from yesterday (and today) by running claws-mail in X, switching to
> the console and trying to attach gdb to it with 'gdb -p $(pgrep claws-mai=
l)'.
>=20
> gdb somehow fails to attach, and after leaving gdb the panic occurs.
>=20
> fk@r500 /usr/crash $cat info.0=20
> Dump header from device /dev/ada0s1b
>   Architecture: amd64          =20
>   Architecture Version: 2      =20
>   Dump Length: 347676672B (331 MB)
>   Blocksize: 512               =20
>   Dumptime: Sat Apr  9 22:48:15 2011
>   Hostname: r500.local         =20
>   Magic: FreeBSD Kernel Dump   =20
>   Version String: FreeBSD 9.0-CURRENT #284 r+1c500d9: Sat Apr  9 15:44:51=
 CEST 2011
>     fk@r500.local:/usr/obj/usr/src/sys/ZOEY
>   Panic String: _mtx_lock_sleep: recursed on non-recursive mutex process =
lock @ /usr/src/sys/kern/kern_exit.c:912
>=20
>   Dump Parity: 1557143341
>   Bounds: 0
>   Dump Status: good
>=20
> fk@r500 /usr/crash $kgdb /boot/kernel/kernel vmcore.0=20
> GNU gdb 6.1.1 [FreeBSD]
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you =
are
> welcome to change it and/or distribute copies of it under certain conditi=
ons.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for detail=
s.
> This GDB was configured as "amd64-marcel-freebsd"...
>=20
> Unread portion of the kernel message buffer:
> panic: _mtx_lock_sleep: recursed on non-recursive mutex process lock @ /u=
sr/src/sys/kern/kern_exit.c:912
>=20
> cpuid =3D 0
> KDB: enter: panic
> panic: from debugger
> cpuid =3D 0
> Uptime: 3m48s
> Physical memory: 1974 MB
> Dumping 331 MB: 316 300 284 268 252 236 220 204 188 172 156 140 124 108 9=
2 76 60 44 28 12
>=20
> Reading symbols from /boot/kernel/zfs.ko...Reading symbols from /boot/ker=
nel/zfs.ko.symbols...done.
> done.
> [...]
> Loaded symbols for /boot/kernel/drm.ko
> #0  doadump () at /usr/src/sys/kern/kern_shutdown.c:250
> 250             if (textdump_pending)
> (kgdb) where
> #0  doadump () at /usr/src/sys/kern/kern_shutdown.c:250
> #1  0xffffffff80531fb7 in kern_reboot (howto=3D260) at /usr/src/sys/kern/=
kern_shutdown.c:418
> #2  0xffffffff80531a51 in panic (fmt=3DVariable "fmt" is not available.
> ) at /usr/src/sys/kern/kern_shutdown.c:591
> #3  0xffffffff803202b7 in db_panic (addr=3DVariable "addr" is not availab=
le.
> ) at /usr/src/sys/ddb/db_command.c:478
> #4  0xffffffff80320761 in db_command (last_cmdp=3D0xffffffff80c9fb60, cmd=
_table=3DVariable "cmd_table" is not available.
> ) at /usr/src/sys/ddb/db_command.c:445
> #5  0xffffffff803209b0 in db_command_loop () at /usr/src/sys/ddb/db_comma=
nd.c:498
> #6  0xffffffff80322a99 in db_trap (type=3DVariable "type" is not availabl=
e.
> ) at /usr/src/sys/ddb/db_main.c:229
> #7  0xffffffff80567ba1 in kdb_trap (type=3D3, code=3D0, tf=3D0xffffff8000=
017740) at /usr/src/sys/kern/subr_kdb.c:533
> #8  0xffffffff807cee06 in trap (frame=3D0xffffff8000017740) at /usr/src/s=
ys/amd64/amd64/trap.c:590
> #9  0xffffffff807b9303 in calltrap () at /usr/src/sys/amd64/amd64/excepti=
on.S:228
> #10 0xffffffff805679fb in kdb_enter (why=3D0xffffffff80955faf "panic", ms=
g=3D0xa <Address 0xa out of bounds>) at cpufunc.h:63
> #11 0xffffffff80531a60 in panic (fmt=3DVariable "fmt" is not available.
> ) at /usr/src/sys/kern/kern_shutdown.c:574
> #12 0xffffffff805222f9 in _mtx_lock_sleep (m=3DVariable "m" is not availa=
ble.
> ) at /usr/src/sys/kern/kern_mutex.c:341
> #13 0xffffffff805223a5 in _mtx_lock_flags (m=3DVariable "m" is not availa=
ble.
> ) at /usr/src/sys/kern/kern_mutex.c:203
> #14 0xffffffff80503789 in proc_reparent (child=3D0xfffffe001290a000, pare=
nt=3D0xfffffe0012e48900) at /usr/src/sys/kern/kern_exit.c:912
> #15 0xffffffff80503ed8 in kern_wait (td=3D0xffffff8000017adc, pid=3DVaria=
ble "pid" is not available.
> ) at /usr/src/sys/kern/kern_exit.c:708
> #16 0xffffffff805043e5 in wait4 (td=3DVariable "td" is not available.
> ) at /usr/src/sys/kern/kern_exit.c:653
> #17 0xffffffff805751ab in syscallenter (td=3D0xfffffe00028838c0, sa=3D0xf=
fffff8000017bb0) at /usr/src/sys/kern/subr_trap.c:344
> #18 0xffffffff807ce8bc in syscall (frame=3D0xffffff8000017c50) at /usr/sr=
c/sys/amd64/amd64/trap.c:910
> #19 0xffffffff807b95cd in Xfast_syscall () at /usr/src/sys/amd64/amd64/ex=
ception.S:384
> #20 0x000000000040cb8c in ?? ()
> Previous frame inner to this frame (corrupt stack?)
> (kgdb) f 14
> #14 0xffffffff80503789 in proc_reparent (child=3D0xfffffe001290a000, pare=
nt=3D0xfffffe0012e48900) at /usr/src/sys/kern/kern_exit.c:912
> 912             PROC_LOCK(parent);
> (kgdb) p *child
> $2 =3D {p_list =3D {le_next =3D 0x0, le_prev =3D 0xffffffff80cba328}, p_t=
hreads =3D {tqh_first =3D 0xfffffe001287c000, tqh_last =3D 0xfffffe001287c0=
10}, p_slock =3D {lock_object =3D {
>       lo_name =3D 0xffffffff80954527 "process slock", lo_flags =3D 720896=
, lo_data =3D 0, lo_witness =3D 0x0}, mtx_lock =3D 4}, p_ucred =3D 0xfffffe=
00427b5a00, p_fd =3D 0x0,=20
>   p_fdtol =3D 0x0, p_stats =3D 0xfffffe0005d82800, p_limit =3D 0x0, p_lim=
co =3D {c_links =3D {sle =3D {sle_next =3D 0x0}, tqe =3D {tqe_next =3D 0x0,=
 tqe_prev =3D 0x0}}, c_time =3D 0, c_arg =3D 0x0,=20
>     c_func =3D 0, c_lock =3D 0xfffffe001290a0f8, c_flags =3D 0, c_cpu =3D=
 0}, p_sigacts =3D 0xfffffe0042634000, p_flag =3D 268460034, p_state =3D PR=
S_ZOMBIE, p_pid =3D 3515, p_hash =3D {
>     le_next =3D 0x0, le_prev =3D 0xffffff8000222dd8}, p_pglist =3D {le_ne=
xt =3D 0x0, le_prev =3D 0xfffffe004a876790}, p_pptr =3D 0xfffffe0002881900,=
 p_sibling =3D {
>     le_next =3D 0xfffffe0042640900, le_prev =3D 0xfffffe00028819f0}, p_ch=
ildren =3D {lh_first =3D 0x0}, p_mtx =3D {lock_object =3D {lo_name =3D 0xff=
ffffff8095451a "process lock",=20
>       lo_flags =3D 21168128, lo_data =3D 0, lo_witness =3D 0x0}, mtx_lock=
 =3D 18446741874728777920}, p_ksi =3D 0xfffffe0005c60150, p_sigqueue =3D {s=
q_signals =3D {__bits =3D {0, 0, 0, 0}},=20
>     sq_kill =3D {__bits =3D {0, 0, 0, 0}}, sq_list =3D {tqh_first =3D 0x0=
, tqh_last =3D 0xfffffe001290a140}, sq_proc =3D 0xfffffe001290a000, sq_flag=
s =3D 1}, p_oppid =3D 0,=20
>   p_vmspace =3D 0xffffffff80cb7760, p_swtick =3D 21105, p_realtimer =3D {=
it_interval =3D {tv_sec =3D 0, tv_usec =3D 0}, it_value =3D {tv_sec =3D 0, =
tv_usec =3D 0}}, p_ru =3D {ru_utime =3D {
>       tv_sec =3D 0, tv_usec =3D 0}, ru_stime =3D {tv_sec =3D 0, tv_usec =
=3D 0}, ru_maxrss =3D 21044, ru_ixrss =3D 544640, ru_idrss =3D 334244, ru_i=
srss =3D 27264, ru_minflt =3D 2745,=20
>     ru_majflt =3D 2158, ru_nswap =3D 0, ru_inblock =3D 3, ru_oublock =3D =
0, ru_msgsnd =3D 134, ru_msgrcv =3D 103, ru_nsignals =3D 0, ru_nvcsw =3D 47=
3, ru_nivcsw =3D 533}, p_rux =3D {
>     rux_runtime =3D 2346291660, rux_uticks =3D 119, rux_sticks =3D 29, ru=
x_iticks =3D 0, rux_uu =3D 948699, rux_su =3D 223223, rux_tu =3D 1171923}, =
p_crux =3D {rux_runtime =3D 0,=20
>     rux_uticks =3D 0, rux_sticks =3D 0, rux_iticks =3D 0, rux_uu =3D 0, r=
ux_su =3D 0, rux_tu =3D 0}, p_profthreads =3D 0, p_exitthreads =3D 0, p_tra=
ceflag =3D 0, p_tracevp =3D 0x0,=20
>   p_tracecred =3D 0x0, p_textvp =3D 0x0, p_lock =3D 0, p_sigiolst =3D {sl=
h_first =3D 0x0}, p_sigparent =3D 20, p_sig =3D 0, p_code =3D 0, p_stops =
=3D 0, p_stype =3D 0, p_step =3D 0 '\0',=20
>   p_pfsflags =3D 0 '\0', p_nlminfo =3D 0x0, p_aioinfo =3D 0x0, p_singleth=
read =3D 0x0, p_suspcount =3D 0, p_xthread =3D 0xfffffe001287c000, p_bounda=
ry_count =3D 0, p_pendingcnt =3D 0,=20
>   p_itimers =3D 0x0, p_magic =3D 3203398350, p_osrel =3D 900034, p_comm =
=3D "claws-mail\000\000\000\000\000\000\000\000\000", p_pgrp =3D 0xfffffe00=
4a876780,=20
>   p_sysent =3D 0xffffffff80c6b320, p_args =3D 0xfffffe0005c8b3c0, p_cpuli=
mit =3D 9223372036854775807, p_nice =3D 0 '\0', p_fibnum =3D 0, p_xstat =3D=
 9, p_klist =3D {kl_list =3D {
>       slh_first =3D 0x0}, kl_lock =3D 0, kl_unlock =3D 0, kl_assert_locke=
d =3D 0xffffffff804fd960 <knlist_mtx_assert_locked>,=20
>     kl_assert_unlocked =3D 0xffffffff804fd940 <knlist_mtx_assert_unlocked=
>, kl_lockarg =3D 0x0}, p_numthreads =3D 1, p_md =3D {md_ldt =3D 0x0, md_ld=
t_sd =3D {sd_lolimit =3D 0,=20
>       sd_lobase =3D 0, sd_type =3D 0, sd_dpl =3D 0, sd_p =3D 0, sd_hilimi=
t =3D 0, sd_xx0 =3D 0, sd_gran =3D 0, sd_hibase =3D 0, sd_xx1 =3D 0, sd_mbz=
 =3D 0, sd_xx2 =3D 0}}, p_itcallout =3D {
>     c_links =3D {sle =3D {sle_next =3D 0x0}, tqe =3D {tqe_next =3D 0x0, t=
qe_prev =3D 0x0}}, c_time =3D 0, c_arg =3D 0x0, c_func =3D 0, c_lock =3D 0x=
0, c_flags =3D 16, c_cpu =3D 0}, p_acflag =3D 16,=20
>   p_peers =3D 0x0, p_leader =3D 0xfffffe001290a000, p_emuldata =3D 0x0, p=
_label =3D 0x0, p_sched =3D 0xfffffe001290a480, p_ktr =3D {stqh_first =3D 0=
x0, stqh_last =3D 0xfffffe001290a430},=20
>   p_mqnotifier =3D {lh_first =3D 0x0}, p_dtrace =3D 0xfffffe0005c7a740, p=
_pwait =3D {cv_description =3D 0xffffffff80954fbe "ppwait", cv_waiters =3D =
0}, p_dbgwait =3D {
>     cv_description =3D 0xffffffff80954fc5 "dbgwait", cv_waiters =3D 0}, p=
_prev_runtime =3D 0, p_racct =3D 0x0}
> (kgdb) p *parent
> $3 =3D {p_list =3D {le_next =3D 0xfffffe004261b000, le_prev =3D 0xfffffff=
f80cba320}, p_threads =3D {tqh_first =3D 0xfffffe0005e0d8c0, tqh_last =3D 0=
xfffffe0005e0d8d0}, p_slock =3D {
>     lock_object =3D {lo_name =3D 0xffffffff80954527 "process slock", lo_f=
lags =3D 720896, lo_data =3D 0, lo_witness =3D 0x0}, mtx_lock =3D 4}, p_ucr=
ed =3D 0xfffffe00427b5a00,=20
>   p_fd =3D 0xfffffe00128b1c00, p_fdtol =3D 0x0, p_stats =3D 0xfffffe00129=
0c800, p_limit =3D 0xfffffe00427b5300, p_limco =3D {c_links =3D {sle =3D {s=
le_next =3D 0x0}, tqe =3D {tqe_next =3D 0x0,=20
>         tqe_prev =3D 0x0}}, c_time =3D 0, c_arg =3D 0x0, c_func =3D 0, c_=
lock =3D 0xfffffe0012e489f8, c_flags =3D 0, c_cpu =3D 0}, p_sigacts =3D 0xf=
ffffe0012e9c000, p_flag =3D 268451842,=20
>   p_state =3D PRS_NORMAL, p_pid =3D 3407, p_hash =3D {le_next =3D 0x0, le=
_prev =3D 0xffffff8000222a78}, p_pglist =3D {le_next =3D 0x0, le_prev =3D 0=
xfffffe0005e59310},=20
>   p_pptr =3D 0xfffffe004261b000, p_sibling =3D {le_next =3D 0x0, le_prev =
=3D 0xfffffe004261b0f0}, p_children =3D {lh_first =3D 0x0}, p_mtx =3D {lock=
_object =3D {
>       lo_name =3D 0xffffffff8095451a "process lock", lo_flags =3D 2116812=
8, lo_data =3D 0, lo_witness =3D 0x0}, mtx_lock =3D 18446741874728777920}, =
p_ksi =3D 0xfffffe0005c5eb60,=20
>   p_sigqueue =3D {sq_signals =3D {__bits =3D {0, 0, 0, 0}}, sq_kill =3D {=
__bits =3D {0, 0, 0, 0}}, sq_list =3D {tqh_first =3D 0x0, tqh_last =3D 0xff=
fffe0012e48a40},=20
>     sq_proc =3D 0xfffffe0012e48900, sq_flags =3D 1}, p_oppid =3D 0, p_vms=
pace =3D 0xfffffe00128c5310, p_swtick =3D 12384, p_realtimer =3D {it_interv=
al =3D {tv_sec =3D 0, tv_usec =3D 0},=20
>     it_value =3D {tv_sec =3D 0, tv_usec =3D 0}}, p_ru =3D {ru_utime =3D {=
tv_sec =3D 0, tv_usec =3D 0}, ru_stime =3D {tv_sec =3D 0, tv_usec =3D 0}, r=
u_maxrss =3D 0, ru_ixrss =3D 0, ru_idrss =3D 0,=20
>     ru_isrss =3D 0, ru_minflt =3D 0, ru_majflt =3D 0, ru_nswap =3D 0, ru_=
inblock =3D 0, ru_oublock =3D 0, ru_msgsnd =3D 0, ru_msgrcv =3D 0, ru_nsign=
als =3D 0, ru_nvcsw =3D 0, ru_nivcsw =3D 0},=20
>   p_rux =3D {rux_runtime =3D 1633285860, rux_uticks =3D 63, rux_sticks =
=3D 44, rux_iticks =3D 0, rux_uu =3D 482021, rux_su =3D 336649, rux_tu =3D =
818671}, p_crux =3D {rux_runtime =3D 770335510,=20
>     rux_uticks =3D 11, rux_sticks =3D 39, rux_iticks =3D 0, rux_uu =3D 84=
947, rux_su =3D 301176, rux_tu =3D 386124}, p_profthreads =3D 0, p_exitthre=
ads =3D 0, p_traceflag =3D 0,=20
>   p_tracevp =3D 0x0, p_tracecred =3D 0x0, p_textvp =3D 0xfffffe00427ae780=
, p_lock =3D 0, p_sigiolst =3D {slh_first =3D 0x0}, p_sigparent =3D 20, p_s=
ig =3D 0, p_code =3D 0, p_stops =3D 0,=20
>   p_stype =3D 0, p_step =3D 0 '\0', p_pfsflags =3D 0 '\0', p_nlminfo =3D =
0x0, p_aioinfo =3D 0x0, p_singlethread =3D 0x0, p_suspcount =3D 0, p_xthrea=
d =3D 0x0, p_boundary_count =3D 0,=20
>   p_pendingcnt =3D 0, p_itimers =3D 0x0, p_magic =3D 3203398350, p_osrel =
=3D 900025, p_comm =3D "bash", '\0' <repeats 15 times>, p_pgrp =3D 0xfffffe=
0005e59300,=20
>   p_sysent =3D 0xffffffff80c6b320, p_args =3D 0xfffffe0002ba2880, p_cpuli=
mit =3D 9223372036854775807, p_nice =3D 0 '\0', p_fibnum =3D 0, p_xstat =3D=
 0, p_klist =3D {kl_list =3D {
>       slh_first =3D 0x0}, kl_lock =3D 0xffffffff804fd660 <knlist_mtx_lock=
>, kl_unlock =3D 0xffffffff804fd680 <knlist_mtx_unlock>,=20
>     kl_assert_locked =3D 0xffffffff804fd960 <knlist_mtx_assert_locked>, k=
l_assert_unlocked =3D 0xffffffff804fd940 <knlist_mtx_assert_unlocked>, kl_l=
ockarg =3D 0xfffffe0012e489f8},=20
>   p_numthreads =3D 1, p_md =3D {md_ldt =3D 0x0, md_ldt_sd =3D {sd_lolimit=
 =3D 0, sd_lobase =3D 0, sd_type =3D 0, sd_dpl =3D 0, sd_p =3D 0, sd_hilimi=
t =3D 0, sd_xx0 =3D 0, sd_gran =3D 0,=20
>       sd_hibase =3D 0, sd_xx1 =3D 0, sd_mbz =3D 0, sd_xx2 =3D 0}}, p_itca=
llout =3D {c_links =3D {sle =3D {sle_next =3D 0x0}, tqe =3D {tqe_next =3D 0=
x0, tqe_prev =3D 0x0}}, c_time =3D 0,=20
>     c_arg =3D 0x0, c_func =3D 0, c_lock =3D 0x0, c_flags =3D 16, c_cpu =
=3D 0}, p_acflag =3D 0, p_peers =3D 0x0, p_leader =3D 0xfffffe0012e48900, p=
_emuldata =3D 0x0, p_label =3D 0x0,=20
>   p_sched =3D 0xfffffe0012e48d80, p_ktr =3D {stqh_first =3D 0x0, stqh_las=
t =3D 0xfffffe0012e48d30}, p_mqnotifier =3D {lh_first =3D 0x0}, p_dtrace =
=3D 0xfffffe0005d85b80, p_pwait =3D {
>     cv_description =3D 0xffffffff80954fbe "ppwait", cv_waiters =3D 0}, p_=
dbgwait =3D {cv_description =3D 0xffffffff80954fc5 "dbgwait", cv_waiters =
=3D 0}, p_prev_runtime =3D 0,=20
>   p_racct =3D 0x0}
>=20
> I'm not sure if switching to the console first matters.
>=20
> Before the panic, the states of gdb and claws-mail were:
>=20
> fk@r500 ~ $procstat -kk $(pgrep claws-mail)
>   PID    TID COMM             TDNAME           KSTACK                    =
  =20
> 15813 100528 claws-mail       initial thread   mi_switch+0x21d thread_sus=
pend_switch+0x103 ptracestop+0x7a cursig+0x4af ast+0x198 doreti_ast+0x1f=20
> fk@r500 ~ $procstat -kk $(pgrep gdb)
>   PID    TID COMM             TDNAME           KSTACK                    =
  =20
> 15823 100928 gdb              -                mi_switch+0x21d sleepq_swi=
tch+0x123 sleepq_catch_signals+0x2a2 sleepq_wait_sig+0x16 _cv_wait_sig+0x14=
c tty_wait+0x48 ttydisc_read+0xd4 ttydev_read+0xab devfs_read_f+0x88 dofile=
read+0xa1 kern_readv+0x60 read+0x55 syscallenter+0x1cb syscall+0x4c Xfast_s=
yscall+0xdd=20
>=20
> I believe I also reproduced the problem with a kernel from Tuesday,
> but dumping core from ddb failed so I can't check.
>=20
> I cannot reproduce the panic with a kernel from 2011-03-12
> which I haven't deleted yet, but didn't try to bisect it further.
>=20
> gdb can't attach to claws-mail either, but the panic doesn't occur:
>=20
> fk@r500 ~ $gdb -p $(pgrep claws-mail)
> GNU gdb 6.1.1 [FreeBSD]
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you =
are
> welcome to change it and/or distribute copies of it under certain conditi=
ons.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for detail=
s.
> This GDB was configured as "amd64-marcel-freebsd".
> Attaching to process 3432
> /usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:=
1444: i
> nternal-error: legacy_fetch_link_map_offsets called without legacy link_m=
ap supp
> ort enabled.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Quit this debugging session? (y or n) y
>=20
> /usr/src/gnu/usr.bin/gdb/libgdb/../../../../contrib/gdb/gdb/solib-svr4.c:=
1444: i
> nternal-error: legacy_fetch_link_map_offsets called without legacy link_m=
ap supp
> ort enabled.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
> Create a core file of GDB? (y or n) n
>=20
> In related news, the kernel from yesterday also seems to panic/hang/whate=
ver
> when claws-mail segfaults due to an invalid memory access, but as I was r=
unning
> X, I got no core dumps for those problems either.

For the first problem, try patch at the end.

Regarding the 'panic/hang/whatever', I cannot reproduce it with a program
that specifically access unmapped memory. You would need to catch core
dump and provide the backtrace.

diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 5fec31b..2d35ed5 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -903,15 +903,19 @@ loop:
 void
 proc_reparent(struct proc *child, struct proc *parent)
 {
+	int locked;
=20
 	sx_assert(&proctree_lock, SX_XLOCKED);
 	PROC_LOCK_ASSERT(child, MA_OWNED);
 	if (child->p_pptr =3D=3D parent)
 		return;
=20
-	PROC_LOCK(parent);
+	locked =3D PROC_LOCKED(parent);
+	if (!locked)
+		PROC_LOCK(parent);
 	racct_add_force(parent, RACCT_NPROC, 1);
-	PROC_UNLOCK(parent);
+	if (!locked)
+		PROC_UNLOCK(parent);
 	PROC_LOCK(child->p_pptr);
 	racct_sub(child->p_pptr, RACCT_NPROC, 1);
 	sigqueue_take(child->p_ksi);

--KEQY95CNCHRmtrVV
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAk2hylYACgkQC3+MBN1Mb4hNmACghS1QdoHXjnkmm1prDKizRcAD
8OMAmgPRn9T8JuIvI7vyaWE6LczVdrTG
=R4wT
-----END PGP SIGNATURE-----

--KEQY95CNCHRmtrVV--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110410151847.GT78089>