-
Notifications
You must be signed in to change notification settings - Fork 794
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
Switching between free-threaded and standard ABI does not invalidate build cache #4882
Comments
Managed to trigger this locally. Here are steps to reproduce the bug. This assumes you have a clone of the bcrypt repo and that you have 3.13.1 and 3.13.1t installed via pyenv and nox is installed into both interpreter's global environments. pyenv global 3.13.1
cd bcrypt
nox -fb virtualenv -s tests
rm -r .nox
pyenv global 3.13.1t
nox -fb virtualenv -s tests The second invocation uses a free-threaded interpreter, but it re-uses the You should see a segmentation fault inside free-threaded Python trying to import bcrypt. This doesn't work because the bcrypt module was compiled with the GIL-enabled ABI.
|
I tried and failed to fix this today following a suggestion from @davidhewitt: try adding For some reason I don't understand, that doesn't work. See the One odd thing is that if I use Take a look at this copy/paste from a terminal session where I demonstrate this behavior: https://gist.github.com/ngoldbaum/10ec27e807e6b1668890e31afaa8da77 I had to hack the diff --git a/noxfile.py b/noxfile.py
index 4b1cd65..f83204a 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -7,7 +7,7 @@ nox.options.default_venv_backend = "uv|virtualenv"
@nox.session
def tests(session: nox.Session) -> None:
session.install("coverage")
- session.install(".[tests]")
+ session.install(".[tests]", "-v")
session.run(
"coverage", "run", "-m", "pytest", "--strict-markers", *session.posargs Maybe this is a cargo caching bug? Deleting the file and recreating it the file with different content somehow doesn't trigger the |
I can trigger the same behavior in a test Rust project, so I think this is a cargo bug or a shortcoming of the |
Until the upstream issue is fixed I think I have at least a way to generate a nicer error message. If a host config file is found, instead of just blindly trusting it, we could call We could restrict the check for things we know definitely won't work, like switching from a GIL-disabled to GIL-enabled build or vice verse. |
Argh, no, that doesn't work because the build script would need to run a second time, which of course it can't unless cargo tells it to. Maybe this is just something we need to document for now as a possible issue people might run into? |
Bug Description
See this bcrypt PR, which fixed a caching issue seen on github actions that led to a segfault. IMO this caching issue should have just led to a rebuild rather than a silently broken build.
Steps to Reproduce
I've only been able to trigger this on bcrypt's CI, but now that I understand what's happening I suspect that if you build PyO3 (or a project that depends on PyO3) with a gil-enabled interpreter and then try to rebuild the project with a free-threaded interpreter but keeping the build cache, you will get a successful build but the python extension will be broken.
Your operating system and version
MacOS
Your Python version (
python --version
)3.13.1
Your Rust version (
rustc --version
)1.84.0
Your PyO3 version
0.23.4
How did you install python? Did you use a virtualenv?
github actions setup-python action
Additional Info
No response
The text was updated successfully, but these errors were encountered: