Subject: kern/23266: topdown uvm is broken with threaded programs
To: None <gnats-bugs@gnats.netbsd.org>
From: None <hira@po6.nsk.ne.jp>
List: netbsd-bugs
Date: 10/25/2003 19:22:25
>Number:         23266
>Category:       kern
>Synopsis:       topdown vm is broken with threaded programs
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 25 10:23:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Kouichirou Hiratsuka
>Release:        NetBSD 1.6ZD
>Organization:
>Environment:
System: NetBSD firefly.localdomain 1.6ZD NetBSD 1.6ZD (FIREFLY) #248: Sat Oct 25 15:14:46 JST 2003 hiratuka@firefly.localdomain:/usr/src/sys/arch/i386/compile/FIREFLY i386
Architecture: i386
Machine: i386
>Description:
	I use -current on i386 and I compiled my kernel with topdown vm. On my
	test threaded program (please see How-To-Repeat), following two problem
	has happened.

	First, it fail at the first time by all means. But thereafter it's OK.
	When I executed it twice immediately after boot, it returned a
	following results.

	% ./thread-test
	assertion "t->pt_type != PT_THREAD_UPCALL" failed: file "pthread_sa.c", line 110, function "pthread__upcall"
	zsh: 297 abort (core dumped)  ./thread-test
	% ./thread-test
	thread 1
	
	%

	Second, it is crashed by page fault. I executed it and I made it status
	page out.

	% ps 974
	PID TT STAT    TIME COMMAND
	947 p0 SWa+ 0:00.00 ./thread-test

	And I hit return key on it, then it crashed with this message.

	assertion "t->pt_type != PT_THREAD_UPCALL" failed: file "pthread_sa.c", line 110, function "pthread__upcall"
	zsh: 947 abort (core dumped)  ./thread-test

	These problems don't happen without topdown vm.

>How-To-Repeat:
#include <stdio.h>
#include <pthread.h>

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

int main()
{
    pthread_t t1;

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

    return (0);
}

	On a kernel with "options USE_TOPDOWN_VM", do the following operation.
	1) execute it immediately after boot
	2) execute it, make it status page out and hit return key on it

>Fix:
	Sorry, I don't know.
>Release-Note:
>Audit-Trail:
>Unformatted: