-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
SIGSEGV when using DuckDB and RocksDB #13092
Comments
Hello @loicmathieu, Thanks for sending us a bug. Unfortunately I'm afraid I won't be able to help you too much. From previous Next step can be to compile DuckDB driver with address sanitizer. If you think it's the problem in RocksDD, can you please provide more information. Environment where are you running your code, name and version of Linux distribution, version of RocksDB, hs_error_pid, ... Radek |
@rhubner DuckDB team ask to open an issue here as they are not sure the issue is inside DuckDB or RocksDB. @shoffmeister seems to have debugged this more deeper, maybe you'll find this comment more explanatory: |
I have lost most of knowledge about C++, I guess, but I wonder why the RocksDB dynamic shared object for JNI, bundled inside the distributed JAR, has lots of things in the Specifically,
on x64 Linux yields a long list of items exported from that DSO. Because of the way ELF linking works, all these symbols leak into the global namespace (IIRC), and that then results in symbol resolution either into libstdc++ or into RocksDB, with mixed results. Example:
I do not see why std::random functions should be exported by RocksDB - and it is that which seems to be giving DuckDB quite a bit of a headache. |
For additional commentary - this is a JNI "thing", which I interpret to be a "plugin-like addon". As such, I wonder why this DSO needs to export anything at all beyond the absolute minimum required to interface to the Java JNI wrapper ( By doing so, the complete process ELF namespace gets polluted with symbols from the plugin, with possible side-effects, for lack of isolation. This then is the ELF variant of the Microsoft Windows DLL hell (https://en.wikipedia.org/wiki/DLL_Hell) |
Hello @shoffmeister, thanks for the details, I was obviously looking on it in wrong ways. I will check what we can do. Recenly we have some requirements from Debian maintainers to reduce the amount of exported functions which will help them to track changes in ABI, but it didn't work with the rest of the tools from RocksDB. Maybe in this case we should be able to limit exported symbols only on Radek |
Hello @shoffmeister @loicmathieu, Thanks for example, I was able to reproduce and you are right. When I compile RockDB with hidden symbols, it starts to work. You can check #12944 PR where I did some implementation of hiding private symbols before. Unfortunately I don't know if we will be able to merge this and release RockDBJava with hidden symbols. At the moment It still break some stuff. Please can you try to build and let me know if it works in your environment? cmake: cmake -DCMAKE_BUILD_TYPE=Release -DJNI=ON -S . -B build -DWITH_GFLAGS=ON -DWITH_TESTS=OFF -DWITH_BENCHMARK_TOOLS=OFF -DWITH_TOOLS=OFF
cd build
make -j <number of CPU> rocksdbjava gcc: HIDE_PRIVATE_SYMBOLS=1 make -j <nubmer of CPU> rocksdbjava Radek |
Your branch yields
This will be interesting to try (later), with |
@rhubner many thanks for supplying the build. After running
I could plug
into the pom.xml and rebuild a fat JAR successfully. Alas, when running
For context, my "local" development system has a RocksDB package installed (https://archlinux.org/packages/extra/x86_64/rocksdb/); this would explain that I can launch the process there. So, I see two real problems:
This effectively makes it impossible for me to test the symbol visibility changes inside the reproducing container. I guess updated build instructions / procedures might help to produce a usable JAR? I'll be glad to rebuild and give that another try. |
Hello @shoffmeister
That's very strange. I never experience this behavior. RocksDB should be statically compiled inside librocksdbjava. Can you please check your build system, or send me direct commands which you used for compilation?
I experience this error couple of times, wasn't able to find where it is exactly problem. It happens only under specific condition and it didn't affect out build and tests. Radek |
Hi @rhubner https://github.com/shoffmeister/duckdb_rocksdb_crash/blob/main/rebuild-rocksdb.bash is my build setup; in the repo at large I am trying to persist my knowledge. Locally I am using a directory structure
If you mirror that, all of that should be working fine for you. My "local" development system is Arch Linux.
That kicks the Java process with a core dump on my side, tough. |
@rhubner I have managed to get a reproducible build up and running, with changes to https://github.com/shoffmeister/duckdb_rocksdb_crash/blob/main/rebuild-rocksdb.bash That reproducible build (now) creates a JNI which is statically linked - so success on that front. The script https://github.com/shoffmeister/duckdb_rocksdb_crash/blob/main/reproduce.bash can be used to test the self-built JAR with the self-built JNI shared object inside. This should print
so, effectively, print "Wombat connected" twice (and some docker-related noise in between). I have full success with a self-built binary. Looking at the self-built JNI itself,
also shows the success of your initiative in #12944 |
Hello @shoffmeister, What is even more strange, when I compile on Ubuntu 24.04, it even works without hiding symbols. I suspect linker on Centos 6. But it's only suspicion, need to do more research. Radek |
Hello @loicmathieu @shoffmeister, I did little bit more testing and it doesn't look good.
Original
As you can see, it removed some symbols from output library, but it didn't remove the Builtools :
Maybe C++ experts @pdillinger or @ajkr can help. Radek |
Expected behavior
Using both RocksDB (via Kafka Streams) and the DuckDB JDBC driver works.
Actual behavior
When both RockDB (via Kafka Streams) and the DuckDB JDBC driver are in the classpath, as soon as we try to use the DuckDB driver the JVM will SIGSEV.
The exact same code on the same JVM and the same OS will not SIGSEGV if the RocksDB native library is not loaded.
This has been raised at DuckDB side but they ask to raise it at RockDB side also, see duckdb/duckdb-java#14
Forcing to pre-load libstdc fixes the issue but as we deliver a product that can be installed by users on environments we didn't manage this cannot be an issue for us.
Steps to reproduce the behavior
This is enough to trigger the crash:
https://github.com/Mause/duckdb_rocksdb_crash/blob/main/src/test/java/com/mycompany/app/AppTest.java
The text was updated successfully, but these errors were encountered: