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
New matmul operator crashes modules compiled with CPython3.4 #67209
Comments
When an extension module is compiled with CPython3.4, the nb_matrix_multiply slot is not filled, and no memory is allocated for it. In Python 2.7 there are flags like Py_TPFLAGS_HAVE_INDEX to gate the access to recently added slots. I think Python3.5 should have a similar one. |
Here is a test module that segfaults on Python3.5. I compiled with Then I ran python3.5 and: When the module is compiled with 3.5, TypeError is correctly raised. |
This technically falls under the fact that we don't have ABI compatibility between 3.N and 3.(N + 1). |
Oh, has this ABI compatibility requirement changed from the 2.x series? |
We never had compatibility between 2.N and 2.(N + 1) either. |
I would not mind the change, but I've always thought the opposite (except on Windows, where the string Python27.dll is stored in the .pyd) There are traces of this binary compatibility still today in the 3.4 headers: |
Extensions need not to be rebuilt only when using stable ABI: But mytest.c fails to build with -DPy_LIMITED_API so it uses features from outside of stable ABI and must be rebuilt. |
PEP-384 is presented as a new way to write modules that can be loaded by multiple Python versions, specially on Windows. I'm not against changing this rule (after all, I started on Windows platform where all this discussion does not apply), but it should be clearly stated somewhere in the API docs, and also in the "whatsnew" pages (all of them?) |
This is why C-extensions' PEP-3147 file tags depend on Python version. I agree the policy could stand to be documented. |
There was probably an informal "best effort ABI compatibility" in 2.x that we de facto dropped in 3.x. Otherwise, as Amaury points out, several Py_TPFLAGS_HAVE_XXX flags would have no purpose. |
@encukou Is any of this still relevant? |
It's not. If compiling with 3.4 and then importing in 3.5 ever worked, it was a coincidence. The flags Docs have been improving over time, but even 3.3 mentions “the API compatibility does not extend to binary compatibility” (except with stable ABI). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: