GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||
GeezerVison is showing github.com — GH-93252: Fix error handling for failed Python calls by brandtbucher · Pull Request #94693 · python/cpython Conversation
|
| PyObject **base = (PyObject **)frame; | ||
| // Make sure that this is, indeed, the top frame. We can't check this in | ||
| // _PyThreadState_PopFrame, since f_code is already cleared at that point: | ||
| assert(base + frame->f_code->co_framesize == tstate->datastack_top); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@pablogsal, just curious: does adding this assert (and not the fix) make tons of tests crash on your build?
If so, my theory is that your compiler is optimizing out the old assert, since the failing case is always undefined behavior according to the C standard.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I will test this night or tomorrow, but I checked and I was indeed compiling in debug mode with asserts, so the old assert should have triggered. I'm curious to see what's going on so I will also investigate that, but that won't affect this issue or the PR, is just that I'm very curious to see what's going on there :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well, even if asserts were turned on, the inequality comparison between the pointers would be undefined if they're part of different allocations. Which is exactly the situation it was checking for!
So if the compiler could somehow prove that the comparison it was always true when the result was defined, it could have optimized it into assert(1) or something.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
But yeah, it doesn't affect this PR. The thing that's better about this new assert is that it's never undefined, and we don't need to overflow our stack chunk to trigger it. One failed call should do it (which is why so many tests crash if you add this without the fix).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
So if the compiler could somehow prove that the comparison it was always true when the result was defined, it could have optimized it into
assert(1)or something.
I don't think so because I was compiling with -O0. If the compiler was being smart there I want my money back 🤣
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Great work 👌
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertIsInstance(res, dict) | ||
| self.assertEqual(list(res.items()), expected) | ||
|
|
||
| def test_frames_are_popped_after_failed_calls(self): |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not that it matters much, but maybe you want to add the CPython specific decorator
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I thought about that, but I figure that this should still pass on any CPython implementation. If you somehow crash here, it's a bug, right? 😉
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we have been approaching these kind of tests in different ways so it doesn't matter :)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
🤖 New build scheduled with the buildbot fleet by @brandtbucher for commit 5b46418 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Not sure why some of the Warnings: Error: Maybe related to #93649? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Ah, yes, it is: #94549 (comment) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks @brandtbucher for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…94693) (cherry picked from commit 8a285df) Co-authored-by: Brandt Bucher <[email protected]>
|
GH-94699 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Post commit LGTM.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
FYI, I have fixed the WASM buildbot issues in #94695. Once dependency was wrong and a directory was missing for OOT builds. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…thonGH-94693) (cherry picked from commit 8a285df) Co-authored-by: Brandt Bucher <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.