Subject: kern/23619: panic: gdt_get_slot (ktruss'ing threaded apps panics kernel)
To: None <gnats-bugs@gnats.netbsd.org>
From: Christian Biere <christianbiere@gmx.de>
List: netbsd-bugs
Date: 12/02/2003 04:25:15
>Number:         23619
>Category:       kern
>Synopsis:       panic: gdt_get_slot (ktruss'ing threaded apps panics kernel)
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 02 04:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Christian Biere
>Release:        NetBSD 1.6ZF
>Organization:
>Environment:
System: NetBSD cyclonus 1.6ZF NetBSD 1.6ZF (STARSCREAM) #0: Sun Nov 30 01:56:21 CET 2003 bin@cyclonus:/usr/build/obj/sys/arch/i386/compile/STARSCREAM i386
Architecture: i386
Machine: i386
>Description:

I've just noticed that using ktruss with any threaded applications panics
the kernel after a few seconds. This problem must be rather new because
I've used ktruss before for e.g., Mozilla and had no panics.


panic: gdt_get_slot botch 2
Begin traceback...
gdt_get_slot(dbe12ff0,dbdbeb94,dbe0eecc,c01ef156,dbe0f000) at netbsd:gdt_get_slot+0xa6
tss_alloc(dbe0f000,1,2,7,0) at netbsd:tss_alloc+0xa
cpu_lwp_fork(dbdbeb0c,dbdbeb94,0,0,c01ee4b4) at netbsd:cpu_lwp_fork+0x86
newlwp(dbdbeb0c,d3a5ed10,dbe0f000,0,0) at netbsd:newlwp+0xaf
sa_newcachelwp(dbdbeb0c,0,0,dbdbeb0c,d3a5ed10) at netbsd:sa_newcachelwp+0x5a
sa_switchcall(dbdbeb0c,1f,1f,1f,1f) at netbsd:sa_switchcall+0x4a
End traceback...
syncing disks...

panic: gdt_get_slot botch 2
#0  0x00000001 in ?? ()
No symbol table info available.
#1  0xc01e755e in cpu_reboot (howto=197300224, bootstr=0x0)
    at /usr/build/src/sys/arch/i386/i386/machdep.c:769
No locals.
#2  0xc018c51c in panic (
    fmt=0x1000 "\220ú\214È\216Ø\216Ðf1ö\214ÎfÁæ\004f\211ðf\005P")
    at /usr/build/src/sys/kern/subr_prf.c:242
	bootopt = 197296128
#3  0xc01e679a in gdt_get_slot ()
    at /usr/build/src/sys/arch/i386/i386/gdt.c:248
	slot = -609105104
#4  0xc01e6806 in tss_alloc (pcb=0xdbb6d000)
    at /usr/build/src/sys/arch/i386/i386/gdt.c:281
	slot = -609105104
#5  0xc01ef156 in cpu_lwp_fork (l1=0xdbb1caa8, l2=0xdbb1cb30, stack=0x0, 
    stacksize=0, func=0xc01ee4b4 <child_return>, arg=0xdbb1cb30)
    at /usr/build/src/sys/arch/i386/i386/vm_machdep.c:187
	pcb = (struct pcb *) 0xdbb6d000
	tf = (struct trapframe *) 0xdbb1cb30
	sf = (struct switchframe *) 0xdbb70ff0
#6  0xc0175af7 in newlwp (l1=0xdbb1caa8, p2=0xd39a6cec, uaddr=3686207472, 
    inmem=0, flags=0, stack=0x0, stacksize=0, func=0xc01ee4b4 <child_return>, 
    arg=0x0, rnewlwpp=0xdbb6cf4c) at /usr/build/src/sys/kern/kern_lwp.c:503
	l2 = (struct lwp *) 0xdbb1cb30
	s = 0
#7  0xc017ac2a in sa_newcachelwp (l=0xdbb1caa8)
    at /usr/build/src/sys/kern/kern_sa.c:976
	p = (struct proc *) 0xd39a6cec
	l2 = (struct lwp *) 0xdbb1cb30
	uaddr = 3686191104
	inmem = 0
#8  0xc017ab8a in sa_switchcall (arg=0xdbb1caa8)
    at /usr/build/src/sys/kern/kern_sa.c:953
	l = (struct lwp *) 0xdbb1caa8
	p = (struct proc *) 0x100000
	sa = (struct sadata *) 0xd39ac040
	f = 1048576


     $NetBSD: machdep.c,v 1.543 2003/10/28 22:52:53 mycroft Exp $
     $NetBSD: subr_prf.c,v 1.93 2003/08/07 16:31:53 agc Exp $
     $NetBSD: gdt.c,v 1.30 2003/06/23 11:01:18 martin Exp $
     $NetBSD: vm_machdep.c,v 1.112 2003/10/27 14:11:47 junyoung Exp $
     $NetBSD: kern_lwp.c,v 1.15 2003/11/04 10:33:15 dsl Exp $
     $NetBSD: kern_sa.c,v 1.46 2003/11/28 08:18:03 scw Exp $

>How-To-Repeat:

$ ktruss -dio /tmp/bla.log thread_test
thread 1
thread 1
thread 1
thread 1

*PANIC*

--<cut here>--
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

void thread_func(int x)
{
	for (;;) {
		printf("thread %d\n", x);
		sleep(1);
	}
}

int main()
{
	pthread_t t;

	pthread_create(&t, NULL, (void *)thread_func, (void *)1);
	pthread_join(t, NULL);

	return (0);
}
--<cut here>--

Compiled with:
cc -Wall -o thread_test thread_test.c -lpthread

>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: