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

crash in absl::~Flag when used in python along with PyTorch #944

Closed
mandeeplearning opened this issue Nov 22, 2023 · 2 comments
Closed

crash in absl::~Flag when used in python along with PyTorch #944

mandeeplearning opened this issue Nov 22, 2023 · 2 comments

Comments

@mandeeplearning
Copy link

mandeeplearning commented Nov 22, 2023

FLAGS_version and FLAGS_minloglevel are exported in the sentencepiece shared library and can be interposed with the same named symbols from other shared libraries such as pytorch's c10. When using sentencepiece from python along with pytorch, this causes a crash in the Flag destructor due to the sentencepiece Flag object being larger than the standard absl Flag object.

For example: #905 #560 #579

One possible fix is to use -Bsymbolic

diff --git a/python/setup.py b/python/setup.py
index fdf9394..9b8cb42 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -96,6 +96,8 @@ class build_ext(_build_ext):
     else:
       cflags.append('-Wl,-strip-all')
       libs.append('-Wl,-strip-all')
+    if sys.plaform == 'linux:
+      libs.append('-Wl,-Bsymbolic')
     print('## cflags={}'.format(' '.join(cflags)))
     print('## libs={}'.format(' '.join(libs)))
     ext.extra_compile_args = cflags

Reference: https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic

@h-vetinari
Copy link
Contributor

The abseil situation is IMO quite problematic. See also #869 and #876. I have a branch that fixes some of this (based on 0.1.99, not master), at least for use with an external abseil (which is the basis of the packaging in conda-forge). I've been trying to get some guidance on how and in what form I could contribute back some of those changes, but so far no response in #876 😑

@taku910
Copy link
Collaborator

taku910 commented Feb 19, 2024

Fixed in v0.2.0

@taku910 taku910 closed this as completed Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants