From nobody@FreeBSD.org  Wed Jan 16 09:50:48 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 C517337B404
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 16 Jan 2002 09:50:47 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g0GHol986467;
	Wed, 16 Jan 2002 09:50:47 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200201161750.g0GHol986467@freefall.freebsd.org>
Date: Wed, 16 Jan 2002 09:50:47 -0800 (PST)
From: Torbjorn Granlund <tege@swox.se>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pthread_cancel is ignored
X-Send-Pr-Version: www-1.0

>Number:         33951
>Category:       kern
>Synopsis:       pthread_cancel is ignored
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-threads
>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:    Mon Feb 09 21:31:36 PST 2004
>Last-Modified:  Mon Feb 09 21:31:36 PST 2004
>Originator:     Torbjorn Granlund
>Release:        4.4 (and 4.1, 4.2, 4.3)
>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:
pthread_cancel doesn't work properly.
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0)
does not seem to make any difference.
>How-To-Repeat:
Compile and run the program below.  On machines with properly working
pthreads implementations, five CPU seconds are consumed, then the
program just sleeps.  Using FreeBSD, the created thread keeps crunching
until process termination.

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

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

  for (;;)
    ;
}

int
main()
{
  pthread_t thread;

  pthread_create(&thread, NULL, crunch, 0);
  sleep (5);
  pthread_cancel(thread);
  sleep (100);
  return 0;
}

>Fix:
None.  We have to tell our customer to run the program on any Unix
system except FreeBSD until this is fixed.

>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@macomnet.ru>
To: Torbjorn Granlund <tege@swox.se>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/33951: pthread_cancel is ignored
Date: Wed, 16 Jan 2002 22:07:55 +0300 (MSK)

 Hello,
 
 this bug (feature?) has been already discussed in freebsd-current
 mail list. Could you please take a look at
 
 http://www.FreeBSD.org/cgi/getmsg.cgi?fetch=511867+515812+/usr/local/www/db/text/2001/freebsd-current/20011202.freebsd-current
 
 As a workaround you should add a cancellation point in your for(;;)
 cycle.
 
 -- 
 Maxim Konovalov, MAcomnet, Internet-Intranet Dept., system engineer
 phone: +7 (095) 796-9079, mailto: maxim@macomnet.ru
 
 

From: Torbjorn Granlund <tege@swox.com>
To: Maxim Konovalov <maxim@macomnet.ru>
Cc: freebsd-gnats-submit@FreeBSD.ORG
Subject: Re: kern/33951: pthread_cancel is ignored
Date: 16 Jan 2002 20:17:49 +0100

 Maxim Konovalov <maxim@macomnet.ru> writes:
 
   this bug (feature?) has been already discussed in freebsd-current
   mail list. Could you please take a look at
 
 It is is a feature, then one could wonder what semantics
 PTHREAD_CANCEL_ASYNCHRONOUS has...
 =20=20
   http://www.FreeBSD.org/cgi/getmsg.cgi?fetch=3D511867+515812+/usr/local/ww=
 w/db/text/2001/freebsd-current/20011202.freebsd-current
 =20=20
 Thanks, I looked for similar bug reports, but didn't check the mailing
 list archives.
 
   As a workaround you should add a cancellation point in your for(;;)
   cycle.
 =20=20
 Tried that, but it slows down things unacceptably.
 
 --=20
 Torbj=F6rn

From: Milon Papezik <mmp@actinet.cz>
To: freebsd-gnats-submit@FreeBSD.org, tege@swox.se
Cc: Torbjorn Granlund <tege@swox.se>,
	Maxim Konovalov <maxim@macomnet.ru>
Subject: Re: kern/33951: pthread_cancel is ignored
Date: Tue, 20 May 2003 19:14:02 +0200

 Hi,
 
 the test case listed in this PR works as expected on FreeBSD 4.8-STABLE
 (uname -v: FreeBSD 4.8-STABLE #1: Sun Apr 27 00:26:46 CEST 2003 ...).
 
 I believe this PR can be closed for 4.x branch (sorry I cannot test on 5.x).
 
 	Thank you in advance,
 	Milon Papezik
 --
 mmp@actinet.cz
 
 
Responsible-Changed-From-To: freebsd-bugs->freebsd-threads 
Responsible-Changed-By: kris 
Responsible-Changed-When: Sat Jul 12 18:35:51 PDT 2003 
Responsible-Changed-Why:  
Assign to threads mailing list 

http://www.freebsd.org/cgi/query-pr.cgi?pr=33951 
State-Changed-From-To: open->closed 
State-Changed-By: deischen 
State-Changed-When: Mon Feb 9 21:30:56 PST 2004 
State-Changed-Why:  
This works under -current with libpthread and supposedly 
under -stable with -lc_r. 

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