-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[BUG] GIL lock failure during static initialization of pybind11 from get_internals() within PYBIND11_MODULE
macro
#2909
Comments
Here's a minimal repo that produces the same error for me on an AWS mac instance: And here's a stackoverflow question about the same issue: |
I'm not an expert on this, just trying to make a connection in hopes that the comments here will help with the background: #2479 I think this will get resolved only if an affected person digs in and figures out a solution (PR). |
Thanks @wgledbetter. Unfortunately, adding /// Also standard libs
#ifndef PYBIND11_STDLIB
# if defined(_LIBCPP_VERSION)
# define PYBIND11_STDLIB "_libcpp"
# elif defined(__GLIBCXX__) || defined(__GLIBCPP__)
# define PYBIND11_STDLIB "_libstdcpp"
# else
# define PYBIND11_STDLIB ""
# endif
#endif so another package could be using pybind11, registering the same "id", and later when I try to import, this condition is satisfied: @rwgk Although I am now pretty confident that my issue is not associated with symbol visibility, when I figure this out, I'll see what I can do about adding an option to |
Sounds good. Just to make sure, are you already aware of this? pybind11/include/pybind11/detail/common.h Line 19 in 0e01c24
TBH I don't have a full understanding of how this interacts with |
Ah yeah, I found that very recently.
Adding |
Shockingly this was fixed by not linking to target_link_libraries(<target> ${PYTHON_LIBRARIES}) was changed to if(NOT APPLE)
target_link_libraries(<target> ${PYTHON_LIBRARIES})
endif() |
Issue description
Essentially, within Travis CI on macOS builds, any attempt to import my pybind11 module results in:
I believe I've tracked it down to approximately
pybind11/include/pybind11/detail/internals.h
Line 263 in 0e01c24
The detailed description is at NERSC/timemory#126.
Reproducible example code
I've used pybind11 many, many times in the past and I've never seen this before. I cannot reproduce it on my local macOS, only during CI. If I could reproduce it, I'd fix it myself and create a PR but I can't even get sanitizers to work:
I've tried using the above env but I'm pretty sure its being ignored by macOS because of their security policies.
I've noticed that
pybind11_add_module
adds-fvisibility=hidden
, what is the reasoning behind this? Is it just for faster loading and protection against two modules using the different versions of the same TPL? Or does is also protect provide something important for the pybind11 internals? I ask bc I've had to bypass that bc of a TPL indirectly linked in not working from Python because of it.Any insight would be helpful.
The text was updated successfully, but these errors were encountered: