Subject: panic: kernel diagnostic assertion "lwp_locked(l, &l->l_cpu->ci_schedstate.spc_lwplock)" failed
To: NetBSD current <current-users@NetBSD.org>
From: Nicolas Joly <njoly@pasteur.fr>
List: current-users
Date: 05/31/2007 00:31:50
--0F1p//8PRICkK4MW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


Hi,

I just encountered a kernel diagnostic assertion panic, while trying
to debug a fork()/clone() problem on my -current NetBSD/amd64 under
compat_linux.

panic: kernel diagnostic assertion "lwp_locked(l, &l->l_cpu->ci_schedstate.spc_lwplock)" failed: file "/local/src/NetBSD/src/sys/kern/kern_synch.c", line 559

I was able to reproduce it with a native application too. Run a
process that will call fork(), stop the chils after fork with `sysctl
-w proc.<pid>.stopfork=1', and finally attach the stopped child with gdb.

njoly@lanfeust [tmp/syscall]> uname -a
NetBSD lanfeust.sis.pasteur.fr 4.99.20 NetBSD 4.99.20 (LANFEUST_DEVEL) #20: Wed May 30 18:51:24 CEST 2007  njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST_DEVEL amd64

njoly@lanfeust [tmp/syscall]> file fork
fork: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), for NetBSD 4.99.20, dynamically linked (uses shared libs), not stripped
njoly@lanfeust [tmp/syscall]> ./fork
father pid 1722
child pid 746

njoly@lanfeust [tmp/syscall]> sysctl -w proc.1722.stopfork=1
proc.1722.stopfork: 0 -> 1
njoly@lanfeust [tmp/syscall]> ps
 PID TTY   STAT    TIME COMMAND
 746 ttyp1 T+   0:00.00 ./fork 
1722 ttyp1 S+   0:00.00 ./fork 
njoly@lanfeust [tmp/syscall]> gdb ./fork 746
GNU gdb 6.5
[...]
This GDB was configured as "x86_64--netbsd"...
Attaching to program: /home/njoly/tmp/syscall/fork, process 746
[KERNEL PANIC]

panic: kernel diagnostic assertion "lwp_locked(l, &l->l_cpu->ci_schedstate.spc_lwplock)" failed: file "/local/src/NetBSD/src/sys/kern/kern_synch.c", line 559
Stopped in pid 1310.1 (gdb) at  netbsd:cpu_Debugger+0x5:        leave
db{0}> mach cpu 0
using CPU 0
db{0}> bt
cpu_Debugger() at netbsd:cpu_Debugger+0x5
panic() at netbsd:panic+0x1fc
__assert() at netbsd:__assert+0x21
setrunnable() at netbsd:setrunnable+0x2a7
proc_unstop() at netbsd:proc_unstop+0xfe
sys_ptrace() at netbsd:sys_ptrace+0xb68
syscall_plain() at netbsd:syscall_plain+0x1cf
uvm_fault(0xffff80004cab0250, 0x0, 1) -> e
kernel: page fault trap, code=0
Faulted in DDB; continuing...
db{0}> mach cpu 1
using CPU 1
db{0}> bt
spllower() at netbsd:spllower+0x2e
syscall_plain() at netbsd:syscall_plain+0x1c1
uvm_fault(0xffff80004cab0250, 0x0, 1) -> e
kernel: page fault trap, code=0
Faulted in DDB; continuing...

Thanks in advance,
Regards.

-- 
Nicolas Joly

Biological Software and Databanks.
Institut Pasteur, Paris.

--0F1p//8PRICkK4MW
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fork.c"

#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <unistd.h>

int main() {
  int sts;
  pid_t p, pid;

  printf("father pid %d\n", getpid());
  sleep(5);

  p = fork();
  if (p == -1)
    err(1, "fork failed");
  if (p == 0) {
    return 0; }

  printf("child pid %d\n", p);

  pid = wait(&sts);
  if (pid == (pid_t)-1)
     err(1, "wait failed");

  return 0; }


--0F1p//8PRICkK4MW--