diff options
author | jb <jb@FreeBSD.org> | 1999-08-20 12:17:09 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 1999-08-20 12:17:09 +0000 |
commit | c6637d28b3ca72411273a6044b5ac622089d3bf3 (patch) | |
tree | d47b6c7116b489ccd0ff25b0e0620313075bf068 /lib/libpthread | |
parent | 9deab5cc4784f9cc208ac1f040ef3379f1e59fff (diff) | |
download | FreeBSD-src-c6637d28b3ca72411273a6044b5ac622089d3bf3.zip FreeBSD-src-c6637d28b3ca72411273a6044b5ac622089d3bf3.tar.gz |
When checking if there is a stack to free, observe the fact that it
might have been mmapped, and if so, passing the pointer to free() is
really not a good idea.
[ In the next millenium, when I've taken over the world, I'm going
to ban 8 character tabs. You've been warned. ]
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/thread/thr_fork.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/lib/libpthread/thread/thr_fork.c b/lib/libpthread/thread/thr_fork.c index 8ef8a3c..f2e352c 100644 --- a/lib/libpthread/thread/thr_fork.c +++ b/lib/libpthread/thread/thr_fork.c @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: uthread_fork.c,v 1.10 1999/06/20 08:28:23 jb Exp $ + * $Id: uthread_fork.c,v 1.11 1999/08/05 12:15:11 deischen Exp $ */ #include <errno.h> #include <string.h> @@ -131,11 +131,28 @@ fork(void) if (pthread_save->attr.stackaddr_attr == NULL && pthread_save->stack != NULL) - /* - * Free the stack of the - * dead thread: - */ - free(pthread_save->stack); + if (pthread_save->attr.stacksize_attr + == PTHREAD_STACK_DEFAULT) { + /* + * Default-size stack. Cache + * it: + */ + struct stack *spare_stack; + + spare_stack + = (pthread_save->stack + + PTHREAD_STACK_DEFAULT + - sizeof(struct stack)); + SLIST_INSERT_HEAD( + &_stackq, + spare_stack, + qe); + } else + /* + * Free the stack of + * the dead thread: + */ + free(pthread_save->stack); if (pthread_save->specific_data != NULL) free(pthread_save->specific_data); |