From: guenther Date: Thu, 14 Aug 2008 05:15:41 +0000 (+0000) Subject: If the initial thread calls pthread_exit(), don't overwrite its thread X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=9f2c70f0732a3a963c9ef89a14a3a448e88ea700;p=openbsd If the initial thread calls pthread_exit(), don't overwrite its thread structure, as the 'tid' member there is used by other parts of librthread to determine whether the current thread is the initial thread --- diff --git a/lib/librthread/rthread.c b/lib/librthread/rthread.c index 5e8a88de030..97b05fc847a 100644 --- a/lib/librthread/rthread.c +++ b/lib/librthread/rthread.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rthread.c,v 1.35 2008/06/05 21:06:11 kurt Exp $ */ +/* $OpenBSD: rthread.c,v 1.36 2008/08/14 05:15:41 guenther Exp $ */ /* * Copyright (c) 2004,2005 Ted Unangst * All Rights Reserved. @@ -146,9 +146,11 @@ static void _rthread_free(pthread_t thread) { /* catch wrongdoers for the moment */ - memset(thread, 0xd0, sizeof(*thread)); - if (thread != &_initial_thread) + if (thread != &_initial_thread) { + /* initial_thread.tid must remain valid */ + memset(thread, 0xd0, sizeof(*thread)); free(thread); + } } static void