From owner-freebsd-current Sat Sep 19 08:18:25 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA11814 for freebsd-current-outgoing; Sat, 19 Sep 1998 08:18:25 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from chaotic.oz.org (chaotic.oz.org [203.20.237.203]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA11806 for ; Sat, 19 Sep 1998 08:18:21 -0700 (PDT) (envelope-from simon@oz.org) Received: from localhost (localhost [127.0.0.1]) by chaotic.oz.org (8.9.1/8.8.8) with SMTP id BAA09900 for ; Sun, 20 Sep 1998 01:18:01 +1000 (EST) (envelope-from simon@oz.org) Date: Sun, 20 Sep 1998 01:18:00 +1000 (EST) From: Simon Coggins Reply-To: chaos@ultra.net.au To: current@FreeBSD.ORG Subject: free() isn't threads safe! Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG While trying to get a threads program working I noticed it was locking up after it returned a free() error avout recursive call.. This is the code from lib/libc/stdlib/malloc.c void free(void *ptr) { malloc_func = " in free():"; <- isn't there a slim chance this can be changed before the thread is locked? THREAD_LOCK(); if (malloc_active++) { wrtwarning("recursive call.\n"); malloc_active--; return; <--------- Shouldn't the thread be unlocked before returning? } ifree(ptr); UTRACE(ptr, 0, 0); malloc_active--; THREAD_UNLOCK(); return; } Wouldn't something like: void free(void *ptr) { THREAD_LOCK(); malloc_func = " in free():"; if (malloc_active++) { wrtwarning("recursive call.\n"); malloc_active--; THREAD_UNLOCK(); return; } ifree(ptr); UTRACE(ptr, 0, 0); malloc_active--; THREAD_UNLOCK(); return; } Be more sensable? Regards Simon --- +---------------------------------------------------------------+ | Email: chaos@ultra.net.au, chaos@oz.org, simon@bofh.com.au | | http://www.ultra.net.au/~chaos Simon.Coggins@jcu.edu.au. | | Chaos on IRC, IRC Operator for the OzORG Network | +---------------------------------------------------------------+ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message