NetBSD Problem Report #10382

Received: (qmail 11257 invoked from network); 16 Jun 2000 22:14:17 -0000
Message-Id: <200006162213.SAA06798@stratos.motorsport.com>
Date: Fri, 16 Jun 2000 18:13:46 -0400 (EDT)
From: dblock@vestris.com
Reply-To: dblock@vestris.com
To: gnats-bugs@gnats.netbsd.org
Subject: lib/libpthread pthread_detach broken 
X-Send-Pr-Version: 3.95

>Number:         10382
>Category:       lib
>Synopsis:       lib/libpthread pthread_detach broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 16 22:15:00 +0000 2000
>Closed-Date:    Tue May 08 00:12:45 +0000 2001
>Last-Modified:  Tue May 08 00:12:45 +0000 2001
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 	pthread_detach doesn't work
 	usleep doesn't work in a thread
 	sleep blocks the thread

>How-To-Repeat:

 #include <pthread.h>
 #include <stdlib.h>
 #include <stdio.h>

 void * ThreadExecute(void * Arguments) {
   printf("Running thread %d\n", (long) Arguments);
   usleep(1000 * 5);
   printf("Done thread %d\n", (long) Arguments);    
   pthread_exit(NULL);
   return NULL;
 }

 void LaunchThread(long i) {
   printf("Launching thread %d\n", i);
   pthread_t m_ThreadID;
   pthread_attr_t l_ThreadAttributes;
   pthread_attr_init(&l_ThreadAttributes);
   pthread_attr_setdetachstate(&l_ThreadAttributes, PTHREAD_CREATE_DETACHED);
   pthread_create(&m_ThreadID, &l_ThreadAttributes, &ThreadExecute, (void *) i);
   pthread_attr_destroy(&l_ThreadAttributes);
   printf("Launched thread %d (%d)\n", i, m_ThreadID);
 }

 int main(void) {
   for (long i = 0; i<10;i++)
     LaunchThread(i);

   while(1)
     sleep(1);

   return 0;
 }


>Fix:
	The thread would launch with a pthread_join(NULL, NULL),
	but this is not an expected behaviour. In either case,
	usleep is broken, nor do threads execute in a concurent
	manner (sleep would block) and threads execute one after
	another.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->lib-bug-people 
Responsible-Changed-By: fair 
Responsible-Changed-When: Mon Jun 26 21:33:39 PDT 2000 
Responsible-Changed-Why:  
Malformed PR maually reformatted and assigned to the proper default 
responsible party. 

From: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
To: dblock@vestris.com
Cc:  
Subject: lib/10382
Date: Sun, 6 May 2001 14:47:47 +0200

 Hi!

 I'm a bit confused about this PR -- NetBSD doesn't have a pthreads
 library. So what pthreads library are you talking about?

 Bye,
  Thomas

 -- 
 Thomas Klausner - wiz@danbala.tuwien.ac.at
 The secret of life is honesty and fair dealing. If you can fake that,
 you've got it made. -- Groucho Marx
State-Changed-From-To: open->closed 
State-Changed-By: wiz 
State-Changed-When: Mon May 7 17:11:28 PDT 2001 
State-Changed-Why:  
This probably was a problem with one of the pthreads packages, since 
NetBSD doesn't have a threads library currently. 
Sadly, submitter doesn't remember which one; so I'll just close this PR. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.