dlopen() and dlclose() are not MT-safe?
- From: Kazuaki Oda <kaakun@xxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 23:32:09 +0900
Hello,
I compiled the following code on 6.1-PRERELEASE and ran:
dltest.c
----------------------------------------------------------------------
#include <err.h>
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#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
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: dlopen() and dlclose() are not MT-safe?
- From: Kostik Belousov
- Re: dlopen() and dlclose() are not MT-safe?
- Prev by Date: Re: 6.1 libpthread: pthread_create and _pq_insert_tail: Already in priority queue
- Next by Date: Re: Installation from USB pen
- Previous by thread: 6.1 libpthread: pthread_create and _pq_insert_tail: Already in priority queue
- Next by thread: Re: dlopen() and dlclose() are not MT-safe?
- Index(es):
Relevant Pages
- Help in Java swings(internal Frame)
... public int getSize() ... public void valueChanged{ ... private
JScrollPane scrollPane1; ... public class PeakContainer extends JInternalFrame ...
(comp.lang.java.programmer) - [PATCH,RFC 2.6.14 09/15] KGDB: SuperH-specific changes
... This adds basic support for KGDB on SuperH as well as adding some architecture ...
-static int kgdb_uart_getchar ... -static void kgdb_uart_putchar ... * The
command-line option can include a serial port specification ... (Linux-Kernel) - problem in java swings
... public int getSize() ... public void valueChanged{ ... private
JScrollPane scrollPane1; ... public class PeakContainer extends JInternalFrame ...
(comp.lang.java.programmer) - ToolTips in a View and TTN_NEEDTEXT
... extern int g_minWorkPeriod; ... void CDayView::CreateAllFonts ...
void CDayView::DrawDayLog(CDC* pDC) ... BOOL CDayView::TimeToY ... (microsoft.public.vc.mfc) - [PATCH 6/20] FRV: Fujitsu FR-V CPU arch implementation part 4
... +static void register_irq_proc (unsigned int irq); ... (Linux-Kernel)