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
torch/_C.so exports a symbol named "state" #11471
Comments
I'll add that you can verify that the symbol
|
yes, we export a global symbol called cc: @gchanan is it still exported on master? |
ifduyue
pushed a commit
to redis/hiredis-py
that referenced
this issue
Sep 13, 2018
Previously, the variable could alias variables named state in other shared objects, which was causing segfaults when imported after pytorch. This change makes it less likely that they overlap and cause undefined behavior. See also pytorch/pytorch#11471
Closing due to age |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue description
Importing both pytorch and hiredis into the same python program often results in a segfault.
After much debugging, I was able to trace this back to the fact that both shared objects export a symbol named
state
, which causes hiredis to overwrite pytorch's internal variables with its own internal state.Code example
I can reproduce this consistently with:
Note that the segfault happens when the interpreter exits, not during the import
Stack trace:
System Info
I think this only happens in builds with GPU support.
Potential Fix
I'd like to suggest that this issue is fixed by compiling all the shared object files with
-fvisibility=hidden
on gcc/clang, and then defining the*_API
macros to set__attribute__((__visibility__("default")))
when compiling. Note that part of the machinery to do this is already in place, but not consistently used (eg.AT_API
has the define on master, whileTHC_API
does not. There is build code to detect the flagfvisibility=hidden
, but it doesn't appear to be set for most of the libraries)Fixing it this way should eliminate this entire class of errors.
I can write a PR that does this, if that would help.
The text was updated successfully, but these errors were encountered: