-
-
Notifications
You must be signed in to change notification settings - Fork 30.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
ZoneInfo comparison fails on free-threaded build #125243
Comments
To trigger it, have a rust toolchain and Python installed, clone the PyO3 repo and execute the following command:
You may also hit some other test failures related to importing errors in the |
I'm having a bit of trouble reproducing this. I first removed the When I run:
I get:
Is that expected? If I run all the tests, like in your command, I get lots of failures, including:
Is that expected? I also tried with the environment variable
|
@ngoldbaum here's a draft PR that fixes the non-threadsafe cache in I'm still having trouble testing this and it looks like the accesses to (I posted this on the wrong issue originally) |
Lock `ZoneInfoType` to protect accesses to `ZONEINFO_STRONG_CACHE`. Refactor the `tp_new` handler to use Argument Clinic so that we can just use `@critical_section` annotations on the relevant functions. Also use `PyDict_SetDefaultRef` instead of `PyDict_SetDefault` when inserting into the `TIMEDELTA_CACHE`.
OK, it turns out that it's very important to use a Python installation built with |
Thanks for investigating and the quick turnaround!
Yes, there is some crude support for "static embedding" but it's horribly broken. Sorry that sunk time for you, we should probably make it harder to allow that.
👍 that looks very likely, we can look into that downstream. |
Bug report
Bug description:
(originally noticed by @davidhewitt in #116738 (comment))
Very infrequently, PyO3 tests for timezone conversions will fail with errors like:
Unfortunately, I don't have an easier way to trigger this besides "run the PyO3 tests over and over until you see a failure", since I think triggering it requires many threads simultaneously using the C API which happens automatically with cargo for the PyO3 tests.
The test code is here:
https://github.com/PyO3/pyo3/blob/eacebb8db101d05ae4ccf0396e314b098455ecd3/src/conversions/chrono_tz.rs#L116-L134
I believe that rust is more or less doing the equivalent of this C code:
This doesn't fail, which makes me suspect triggering it requires touching the C API in other threads.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: