Bug 33952

Summary: Bogus error message from correct phreads code
Product: Base System Reporter: tege <tege>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description tege 2002-01-16 18:00:08 UTC
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 = ?)

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.
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;
}
Comment 1 Archie Cobbs 2002-09-09 23:05:06 UTC
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
Comment 2 Torbjorn Granlund 2002-09-15 18:05:09 UTC
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.

-- 
Torbjörn
Comment 3 Archie Cobbs freebsd_committer freebsd_triage 2002-09-15 18:47:10 UTC
State Changed
From-To: open->closed

Fixed in -stable and -current.