-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-34569: Fix subinterpreter 32-bit ABI, pystate.c/_new_long_object() #9127
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
Conversation
…ers.py.ShareableTypeTests._assert_values`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments below, but there are a couple of high-level things to address.
First, each PR should correspond to one BPO issue. It looks like this PR has fixes for two issues.
Second, I'd expect the fix to involve changes to _long_shared()
and/or _new_long_object()
(in Python/pystate.c
) or even PyLong_AsLongLong()
/PyLong_FromLongLong
/ULONG_MAX
. That said, I'm no expert in this platform-specific C-level stuff, so it may be worth getting feedback from someone else too. :)
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
remove second issue included by accident
I have made the requested changes; please review again. |
Thanks for making the requested changes! @ericsnowcurrently: please review the changes made to this pull request. |
Thanks for making those changes. I'm happy with the code. That said, as implied above I would expect the test to pass as-is. Consequently, this PR should probably not be merged. If there's any urgency to getting a passing test suite then I'd recommend making a PR to skip the test under AIX (as a temporary stopgap). Either way, the BPO issue should stay open until the underlying bug is resolved. |
On 19/09/2018 17:53, Eric Snow wrote:
Thanks for making those changes. I'm happy with the code.
That said, as implied above I would expect the test to pass as-is. `-1` is a legitimate value to pass through a channel. The fact that the test is failing means that it's doing its job: letting us know when there's a bug. :) Most likely, either the code in Python/pystate.c (`_long_shared()` and/or `_new_long_object()`) or the implementation of `PyLong_AsLongLong()`/`PyLong_FromLongLong()`/`ULONG_MAX` needs to be fixed.
Consequently, this PR should probably not be merged. If there's any urgency to getting a passing test suite then I'd recommend making a PR to skip the test under AIX (as a temporary stopgap). Either way, the BPO issue should stay open until the underlying bug is resolved.
Understood. Would it "work" to rename to a different issue number (29970
is an issue already opened for 'test' passing.
As to making it work properly, I am not comfortable enough with
internals to actually make a change - but I will make the time later to
find the line where it goes wrong (basically where the value it is
passed is assigned to the "void".
The 'solution' will be something along the line of
#if 32-bit
do something that typecasts from 32-bit to 64-bit. I do not have enough
experience/knowledge to know if type casting from 32-bit "int" to 64-bit
"int" will work in all cases. As to the test, yes, -1 is a valid value.
-2 would fail - rather any negative value - would fail in the same way.
So, as to my question above - if that is okay, should all the other
tests be passing then I'll change this issue number to 29970. But if I
(better we) have made progress with a real solution we can merge those
changes instead (and revert the test back to original).
Michael
|
afaik - there is a red X because there were issues with the Linux-PR systems. Is there a recognized way to rerun the tests? |
@ericsnowcurrently I have made the requested changes; please review again. Now a change is pystate.c/new_long_object() |
Thanks for making the requested changes! @ericsnowcurrently: please review the changes made to this pull request. |
Misc/NEWS.d/next/Tests/2018-09-09-14-36-59.bpo-34569.okj1Xh.rst
Outdated
Show resolved
Hide resolved
@ericsnowcurrently - Hi! Have you had time to check this is what you intended for me to do? |
@ericsnowcurrently This seems to be a sign extension bug.
It seems that on this platform/compiler, #include <stdio.h>
int main()
{
printf("%lld\n", (long long)(void*)-1);
return 0;
} With GCC:
With XLC:
The code as-is will work, but |
There should probably also be a comment added to state why PyLong_FromVoidPtr was not used, since that would seem most appropriate. The problem is that PyLong_FromVoidPtr explicitly forces the pointer to be unsigned, so you'd never get -1. |
The actual code change here now looks good to me, but I'm not sure where the NEWS entry should go given that the cross-interpreter data channels aren't officially a public API yet. @ericsnowcurrently perhaps leaving the entry in Tests makes the most sense right now, even though the code is actually part of the builtins? |
tl;dr I'll merge this Wednesday Jan 9 (or by the 11th of the latest), unless someone tells me that we could lose info by using Thanks, all, for diving into this. The solution mostly looks good to me. Further, my experience with C intrinsic types at the compiler level is small so I'm willing to defer to Nick's judgement here. :) My only concern is that types match up so there is no loss of information. In the code in pystate.c, the conversions follow this flow: pack:
unpack:
The code relies on the equivalency of If I don't here any objections by next Wednesday then I'll merge it then. |
According to the C99 spec which introduced |
The Lib/test/test__xxsubinterpreters.py test fails in:
ShareableTypeTests.test_int() with the value "-1" when in 32-bit mode (long is 32-bit).
https://bugs.python.org/issue34569