-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash when dlopen'ed library not dlclose'd explicitly #17475
Labels
Comments
sturtivant commented on 2024-03-01T20:37:14ZCreated attachment 1907
main.c |
sturtivant commented on 2024-03-01T20:37:54ZCreated attachment 1908
dynamic_lib.c |
sturtivant commented on 2024-03-01T20:38:43ZCreated attachment 1909
main.d |
sturtivant commented on 2024-03-01T20:39:15ZCreated attachment 1910
dynamic_lib.d |
alphaglosined commented on 2024-03-01T20:51:38ZJust 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? |
sturtivant commented on 2024-03-01T21:50:35Z1.
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. |
alphaglosined commented on 2024-03-01T21:54:15ZWhen using ldc does it crash when druntime is a shared library and initialized?
This will confirm that it is a druntime bug. |
sturtivant commented on 2024-03-01T22:01:52Z> When using ldc does it crash when druntime is a shared library and initialized?
Is this the default for ldc? |
alphaglosined commented on 2024-03-01T22:06:05ZThe default phobos/druntime shared/static may depend upon platform and distribution. |
sturtivant commented on 2024-03-01T22:54:36Z(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)
==== |
sturtivant commented on 2024-03-01T23:09:23Z(In reply to Carl Sturtivant from comment #10)
> (In reply to Richard Cattermole from comment #9)
====
$ ldc2 -c main.d
$ ldc2 -of=main -L-E main.o -L-ldl
$ ldc2 -c --relocation-model=pic dynamic_lib.d
$ ldc2 -of=dynamic_lib.so -shared -relocation-model=pic dynamic_lib.o
(dmd-2.107.0)carl@palmtree ~/Documents/dprogs/dl $ 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)
====
--- looks like the crash options are the default: not shared for main and shared for the dynamic library. |
alphaglosined commented on 2024-03-01T23:33:42ZOkay, ldc and dmd have differing implementations of ``rt.sections_elf_shared``.
With ldc yes, you need to stick with only shared library build of druntime, it cannot be mixed.
From what I can tell it's an ordering problem due to not explicitly loading then unloading druntime in the right order. |
sturtivant commented on 2024-03-01T23:56:42Z(In reply to Richard Cattermole from comment #12)
> From what I can tell it's an ordering problem due to not explicitly loading
> then unloading druntime in the right order.
That's intuitively reasonable. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Carl Sturtivant reported this on 2024-03-01T20:35:03Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24427
CC List
Description
!!!There are attachements in the bugzilla issue that have not been copied over!!!
The text was updated successfully, but these errors were encountered: