[DragonFlyBSD - Bug #2663] (Closed) Strange behaviour when loading a library twice.

bugtracker-admin at leaf.dragonflybsd.org bugtracker-admin at leaf.dragonflybsd.org
Thu Apr 17 09:23:16 PDT 2014

Issue #2663 has been updated by shamaz.

Status changed from New to Closed

Fix committed: 0dc5e56d98ab5fc55416a204886f8b132cc9b7f1

Bug #2663: Strange behaviour when loading a library twice.

* Author: shamaz
* Status: Closed
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
Hello. This is an output of uname:

$ uname -a
DragonFly cyberspace.cyberspace 3.6-RELEASE DragonFly
v3.6.2.2.g063e0-RELEASE #7: Sun Apr 13 09:50:36 MSK 2014
vasily at cyberspace.cyberspace:/usr/obj/usr/src/sys/MYKERNEL

Trying to port common lisp IOLib library on DragonFly, I have encountered a
strange behaviour (of RTLD as I think). Assume you have a library which
mmap's a fixed (with flag MAP_TRYFIXED) region of memory in its
constructor. When your program opens it with dlopen, then closes it with
dlcose and again opens with dlopen, the second call to mmap from the
constructor will fail. Is it OK?

I attach a testing program (test.c). Try to compile it and run with

$ cc -o test test.c
$ ./test /usr/lib/thread/libthread_xu.so.

You will get the following output:

testing /usr/lib/thread/libthread_xu.so
Fatal error 'Cannot allocate red zone for initial thread' at line 275 in
file /usr/src/lib/libthread_xu/thread/thr_in
it.c (errno =

Abort (core dumped)

You can try any other library which is linked against -lpthread or you can
try my own library testlib.c
Compile it as follows:

$ cc -shared -fPIC -o testlib.so testlib.c

And run the test:

$ ./test ./testlib.so

You will get:

testing ./libtest.so
mmap OK
Failed to allocate some space with initialized == 0

In FreeBSD, for example, mmap succeeds two times.

test.c (462 Bytes)
testlib.c (503 Bytes)

You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account

More information about the Bugs mailing list