Jump to page: 1 2
Thread overview
[Issue 24427] Crash when dlopen'ed library not dlclose'd explicitly
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #1 from Carl Sturtivant <sturtivant@gmail.com> ---
Created attachment 1907
  --> https://issues.dlang.org/attachment.cgi?id=1907&action=edit
main.c

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #2 from Carl Sturtivant <sturtivant@gmail.com> ---
Created attachment 1908
  --> https://issues.dlang.org/attachment.cgi?id=1908&action=edit
dynamic_lib.c

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #3 from Carl Sturtivant <sturtivant@gmail.com> ---
Created attachment 1909
  --> https://issues.dlang.org/attachment.cgi?id=1909&action=edit
main.d

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #4 from Carl Sturtivant <sturtivant@gmail.com> ---
Created attachment 1910
  --> https://issues.dlang.org/attachment.cgi?id=1910&action=edit
dynamic_lib.d

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alphaglosined@gmail.com

--- Comment #5 from Richard Cattermole <alphaglosined@gmail.com> ---
Just to clarify:

Does a crash only occur when the executable has druntime linked in and initialized?

If you load a shared library that has druntime linked in, does it also crash if you initialize druntime?

Does this happen with ldc?

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #6 from Carl Sturtivant <sturtivant@gmail.com> ---

1.
lcd did not produce the bug, using --link-defaultlib-shared=false for both the
main program and the dynamic library.

2.
When the dynamic library C source is compiled and linked with -betterC the
error does not occur.

3.
It does crash with druntime initialized in the dynamic library.

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #7 from Richard Cattermole <alphaglosined@gmail.com> ---
When using ldc does it crash when druntime is a shared library and initialized?

This will confirm that it is a druntime bug.

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #8 from Carl Sturtivant <sturtivant@gmail.com> ---
> When using ldc does it crash when druntime is a shared library and initialized?

Is this the default for ldc?

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #9 from Richard Cattermole <alphaglosined@gmail.com> ---
The default phobos/druntime shared/static may depend upon platform and distribution.

--
March 01
https://issues.dlang.org/show_bug.cgi?id=24427

--- Comment #10 from Carl Sturtivant <sturtivant@gmail.com> ---
(In reply to Richard Cattermole from comment #9)
> The default phobos/druntime shared/static may depend upon platform and distribution.

I used the --link-defaultlib-shared=true option which I assume also shares druntime. I found no switch mentioning sharing or statically linking druntime explicitly.

Neither main.c nor dynamic_lib.c will link with --link-defaultlib-shared=true With that false, the C version just works.

By contrast, D source links for all four combinations of true/false for
--link-defaultlib-shared for each build. Three work, one crashes.
====
$ ldc2 -c main.d
$ ldc2 -of=main -L-E main.o -L-ldl --link-defaultlib-shared=false
$ ldc2 -c --relocation-model=pic dynamic_lib.d
$ + ldc2 -of=dynamic_lib.so -shared -relocation-model=pic dynamic_lib.o
--link-defaultlib-shared=true
$ main
Aborting from rt/sections_elf_shared.d(605) Only one D shared object allowed
for static runtime. Link with shared runtime via LDC switch
'-link-defaultlib-shared'.Aborted (core dumped)
====

--
« First   ‹ Prev
1 2