From nobody@FreeBSD.org  Wed Jan 16 09:55:30 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id AA19F37B417
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 16 Jan 2002 09:55:00 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g0GHt0e87109;
	Wed, 16 Jan 2002 09:55:00 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200201161755.g0GHt0e87109@freefall.freebsd.org>
Date: Wed, 16 Jan 2002 09:55:00 -0800 (PST)
From: Torbjorn Granlund <tege@swox.se>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Bogus error message from correct phreads code
X-Send-Pr-Version: www-1.0

>Number:         33952
>Category:       kern
>Synopsis:       Bogus error message from correct phreads code
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 16 10:00:08 PST 2002
>Closed-Date:    Sun Sep 15 10:47:26 PDT 2002
>Last-Modified:  Sun Sep 15 10:47:26 PDT 2002
>Originator:     Torbjorn Granlund
>Release:        4.4 (and 4.2, 4.3, but not fbsd 4.1)
>Organization:
Swox AB
>Environment:
FreeBSD hill.swox.se 4.4-RELEASE FreeBSD 4.4-RELEASE #0: Tue Sep 18 11:57:08 PDT 2001     murray@builder.FreeBSD.org:/usr/src/sys/compile/GENERIC  i386

>Description:
This test case makes the pthreads code print a bogus error message:

Fatal error 'Thread 0x804c400 has called pthread_exit() from a destructor. POSIX 1003.1 1996 s16.2.5.2 does not allow this!' at line ? in file /usr/src/lib/libc_r/uthread/uthread_exit.c (errno = ?)

>How-To-Repeat:
Compile and run the program below.

#include <pthread.h>
#include <unistd.h>

int stop_flag = 0;

void *
crunch(void *ignored)
{
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);

  while (!stop_flag)
    ;
  pthread_exit (0);
}

int
main()
{
  pthread_t thread;

  pthread_create(&thread, NULL, crunch, 0);
  sleep(1);
  pthread_cancel(thread);
  stop_flag = 1;
  sleep(1);
  return 0;
}

>Fix:
None.  We have to tell our customer to run the program on any Unix
system except FreeBSD until this (and the other pthreads bug we've
also reported) are fixed.

>Release-Note:
>Audit-Trail:

From: Archie Cobbs <archie@packetdesign.com>
To: freebsd-gnats-submit@FreeBSD.org, tege@swox.se
Cc:  
Subject: Re: kern/33952: Bogus error message from correct phreads code
Date: Mon, 09 Sep 2002 15:05:06 -0700

 This bug should be fixed in FreeBSD-current and FreeBSD-stable
 (included in the upcoming FreeBSD 4.7-RELEASE).
 
 Could you verify that it works for you now?
 
 Thanks,
 -Archie
 
 __________________________________________________________________________
 Archie Cobbs     *     Packet Design     *     http://www.packetdesign.com

From: Torbjorn Granlund <tege@swox.com>
To: Archie Cobbs <archie@packetdesign.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/33952: Bogus error message from correct phreads code
Date: 15 Sep 2002 19:05:09 +0200

 Archie Cobbs <archie@packetdesign.com> writes:
 
   This bug should be fixed in FreeBSD-current and FreeBSD-stable
   (included in the upcoming FreeBSD 4.7-RELEASE).
   
   Could you verify that it works for you now?
   
 Yes, my test program now runs correctly.
 
 A related bug, kern/33951, still seems present though.  
 Having a complete and working pthreads implementation for 4.7
 would be nice.  After all, this is one a vey few areas where
 FreeBSD is actually *worse* than other Unices.
 
 -- 
 Torbjrn
State-Changed-From-To: open->closed 
State-Changed-By: archie 
State-Changed-When: Sun Sep 15 10:47:10 PDT 2002 
State-Changed-Why:  
Fixed in -stable and -current. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=33952 
>Unformatted:
