Skip to content
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

boost::dll::shared_library self(boost::dll::program_location()); causing issues on Linux #55

Open
dennisklein opened this issue Apr 20, 2021 · 2 comments

Comments

@dennisklein
Copy link

Dear developers,

we are using Boost.DLL for a small plugin system. Some plugins are linked into the executable following this guide: https://www.boost.org/doc/libs/1_76_0/doc/html/boost_dll/tutorial.html#boost_dll.tutorial.linking_plugin_into_the_executable.

The boost::dll::shared_library self(boost::dll::program_location()); statement however is causing two error classes for us (see FairRootGroup/FairMQ#351):

  • On some linux flavors it causes double static initialisation always (not fully understood which config parameter is different on affected systems, see the linked issue above for a reproducer and a table of affected systems)
  • On containerized CentOS 8 Continuous Integration environments we sometimes (20% chance or so) see errors like this: boost::dll::shared_library::load() failed (dlerror system message: /mnt/mesos/sandbox/sandbox/o2-fullci/sw/slc8_x86-64/O2/5964-local1/bin/o2-sim-primary-server-device-runner: cannot dynamically load executable): Bad file descriptor

On a first glance, it looks like boost::dll::shared_library self(boost::dll::program_location()); is implemented with a dlopen("/path/to/executable", ...) on Linux. The Linux manpage also suggests to use dlopen(NULL, ...) for this case. But I am no expert here. Do you have any deeper insight in what might be the underlying issue for the problems described above? Your comments are very much appreciated!

@apolukhin
Copy link
Owner

Our tests do not sow such problem https://www.boost.org/development/tests/develop/developer/dll.html

Could you provide a minified example to reproduce the issue?

@dennisklein
Copy link
Author

dennisklein commented Apr 30, 2021

Could you provide a minified example to reproduce the issue?

See https://github.com/dennisklein/doublestaticinit for a small reproducer. It depends on CMake and singularity. If you do not have those deps, checker.cpp is the program that is run via gdb --batch --command=gdbchecker --args checker with this gdb script: gdbchecker

FairRootGroup/FairMQ#351 shows a table on which systems we see the double static initialization.

On containerized CentOS 8 Continuous Integration environments we sometimes (20% chance or so) see errors like this: boost::dll::shared_library::load() failed (dlerror system message: /mnt/mesos/sandbox/sandbox/o2-fullci/sw/slc8_x86-64/O2/5964-local1/bin/o2-sim-primary-server-device-runner: cannot dynamically load executable): Bad file descriptor

For this issue we believe it could be related to ASLR and not having used PIEs. But we found a workaround. The more important issue to understand/solve would be the double static init.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants