-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Shared library use unsafe because of abseil linkage #579
Comments
Ideally, we would like to get rid of the dependency to absl::Flags from sentencepiece library and remain them only *_main.cc. |
Dynamic linking can lead to incompatibilities. This change can be reverted once google/sentencepiece#579 is resolved.
Dynamic linking can lead to incompatibilities. This change can be reverted once google/sentencepiece#579 is resolved.
In the latest main branch, I've removed the dependency from flags to C++ library. Could you try it? if there is no problem. it will be included in the next release? Please feel free to reopen this issue if necessary. |
No dice, still Edit: seems like I cannot reopen this issue. |
Removed absl::Flags completely from *so and *a library. Could you try the head? |
Works like a charm now. Thanks a lot! |
I am facing the same issue using the latest (v0.1.99) pip package. I also resolved it by building the pip package from source and removing the using absl::flags from src/init.h. |
I am using my own Rust binding to sentencepiece. When I link against sentencepiece statically, things work as expected. However, when I use sentencepiece as a dynamic library, I get
SIGBUS
when a program exists and the destructor ofabsl::Flag
is called:According to the abseil documentation, it's not safe to use Abseil in combination with loading/unloading of dynamic libraries.
It's likely that the compiler flags differ between Rust compilation and compiling of sentencepiece, leading to memory errors.
I modified
src/CMakeList.txt
to not compilethird_party/absl/flags/flag.cc
andinit.cc
into the (shared) library, but into the individual binaries, and I also modified theLOG
macro to not useabsl::GetFlag
. With these changes the program terminates fine without SIGBUS (so apparentlystring_view
does not suffer from the same problem?).I don't have a ready-to use patch/PR, because I am not sure how the
LOG
macro should be adjusted to avoid linkingabsl::Flag
into the shared library.The text was updated successfully, but these errors were encountered: