From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 22 14:36:56 2006 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5F94D16A400 for ; Wed, 22 Mar 2006 14:36:56 +0000 (UTC) (envelope-from kaakun@highway.ne.jp) Received: from mx.highway.ne.jp (pip7.gate01.com [61.122.117.245]) by mx1.FreeBSD.org (Postfix) with ESMTP id CCE5C43D49 for ; Wed, 22 Mar 2006 14:36:55 +0000 (GMT) (envelope-from kaakun@highway.ne.jp) Received: from [219.0.96.106] (helo=[192.168.11.17]) by pop12.isp.us-com.jp with esmtp (Mail 4.20) id 1FM4SD-0000Ez-5L for hackers@freebsd.org; Wed, 22 Mar 2006 23:36:53 +0900 Message-ID: <44215FE9.2070602@highway.ne.jp> Date: Wed, 22 Mar 2006 23:32:09 +0900 From: Kazuaki Oda User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051211) X-Accept-Language: en-us, en MIME-Version: 1.0 To: hackers@freebsd.org Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit Cc: Subject: dlopen() and dlclose() are not MT-safe? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Mar 2006 14:36:56 -0000 Hello, I compiled the following code on 6.1-PRERELEASE and ran: dltest.c ---------------------------------------------------------------------- #include #include #include #include #include #include #define NTHREADS 10 void *func(void *dummy); int main(void) { pthread_t tids[NTHREADS]; int error; int i; for (i = 0; i < NTHREADS; i++) { error = pthread_create(&tids[i], NULL, func, NULL); if (error) errc(1, error, "pthread_create"); } for (;;) sleep(1); /* NOTREACHED */ exit(0); } void *func(void *dummy) { void *h; for (;;) { if ((h = dlopen("/usr/lib/libm.so", RTLD_NOW)) == NULL) errx(1, "dlopen: %s", dlerror()); if (dlclose(h) == -1) errx(1, "dlclose: %s", dlerror()); } /* NOTREACHED */ return (NULL); } ---------------------------------------------------------------------- % cc -Wall -o dltest dltest.c -lpthread % ./dltest ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/rtld.c:2445 Segmentation fault (core dumped) % cc -Wall -o dltest dltest.c -lthr % ./dltest % ld-elf.so.1: assert failed: /usr/src/libexec/rtld-elf/rtld.c:1723 Abort (core dumped) Hmm, it seems dlopen() and dlclose() are not MT-safe. Is this a known issue? -- Kazuaki Oda