From owner-freebsd-hackers Sat Dec 27 19:14:46 1997 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.7/8.8.7) id TAA10693 for hackers-outgoing; Sat, 27 Dec 1997 19:14:46 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from damon.com (root@damon.com [207.170.114.1]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id TAA10683; Sat, 27 Dec 1997 19:14:40 -0800 (PST) (envelope-from dap@damon.com) Received: (from dap@localhost) by damon.com (8.8.3/8.8.3) id VAA25423; Sat, 27 Dec 1997 21:14:36 -0600 (CST) From: Damon Anton Permezel Message-Id: <199712280314.VAA25423@damon.com> Subject: Re: patches for JDK 1.1.5? To: hsu@FreeBSD.ORG (Jeffrey Hsu) Date: Sat, 27 Dec 1997 21:14:36 -0600 (CST) Cc: hackers@hub.freebsd.org In-Reply-To: <199712280023.QAA00226@hub.freebsd.org> from Jeffrey Hsu at "Dec 27, 97 04:23:32 pm" X-Mailer: ELM [version 2.4ME+ PL22 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk "Jeffrey Hsu sez: " > > I have a 1.1.4 port > > It works fairly well, but suffers occasionally from recursive malloc > > calls. > > Copy /usr/src/lib/libc/stdlib/malloc.c and to > src/solaris/java/runtime/malloc_md.c and modify THREAD_LOCK() and > THREAD_UNLOCK() to call sysMonitorEnter(&_malloc_lock) and > sysMonitorExit(&_malloc_lock). > My approach was to redefine malloc to enter/exit a monitor, pick up "_malloc" out of libc, and call the original, in a manner so that I had a general solution which could be used for other libc funcs requiring serialization: void* malloc(size_t size) { void *res; if (!libcInitialized) initLibc(); if (monitorsInitialized) { LIBC_LOCK(LIBC_MALLOC); res = (*libctable[LIBC_MALLOC].addr)(size); LIBC_UNLOCK(LIBC_MALLOC); } else res = (*libctable[LIBC_MALLOC].addr)(size); return res; } I was unable to get this to work, due to some problems with ld.so. I will eventually go back an spend some more time of trying to figure out what was happening there, but with the fallback of just copying libc/.../malloc.c into the source, as you have.