Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GH-93252: Fix error handling for failed Python calls#94693

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
brandtbucher merged 4 commits intopython:mainfrombrandtbucher:failed-call-cleanup
Jul 9, 2022

Conversation

@brandtbucher
Copy link
Member

@brandtbucherbrandtbucher commentedJul 8, 2022
edited by bedevere-bot
Loading

Also, add an assert so that things like this fail much earlier (and more clearly) on debug builds.

@brandtbucherbrandtbucher added interpreter-core(Objects, Python, Grammar, and Parser dirs) type-crashA hard crash of the interpreter, possibly with a core dump needs backport to 3.11only security fixes labelsJul 8, 2022
@brandtbucherbrandtbucher self-assigned thisJul 8, 2022
Comment on lines 6435 to 6438
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);
Copy link
MemberAuthor

Choose a reason for 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.

Copy link
Member

Choose a reason for 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 :)

Copy link
MemberAuthor

Choose a reason for 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 intoassert(1) or something.

Copy link
MemberAuthor

Choose a reason for 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).

Copy link
Member

Choose a reason for 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 intoassert(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 🤣

Copy link
Member

@pablogsalpablogsal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM

Great work 👌

self.assertIsInstance(res,dict)
self.assertEqual(list(res.items()),expected)

deftest_frames_are_popped_after_failed_calls(self):
Copy link
Member

Choose a reason for 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

Copy link
MemberAuthor

Choose a reason for 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? 😉

Copy link
Member

Choose a reason for 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 :)

@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@brandtbucher for commit5b46418 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelJul 8, 2022
@brandtbucher
Copy link
MemberAuthor

brandtbucher commentedJul 8, 2022
edited
Loading

Not sure why some of thewasm32 buildbots are failing, but it looks totally unrelated to these changes:

Warnings:

../../Python/initconfig.c:2284:27: warning: format specifies type 'wint_t' (aka 'int') but the argument has type 'wint_t' (aka 'unsigned int') [-Wformat]../../Python/initconfig.c:2284:42: warning: format specifies type 'wint_t' (aka 'int') but the argument has type 'wint_t' (aka 'unsigned int') [-Wformat]../../Python/pytime.c:297:10: warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion]../../Python/pytime.c:352:14: warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion]../../Python/pytime.c:518:10: warning: implicit conversion from 'long long' to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Wimplicit-const-int-float-conversion]../../Modules/expat/xmlparse.c:3107:9: warning: code will never be executed [-Wunreachable-code]../../Modules/expat/xmlparse.c:4050:9: warning: code will never be executed [-Wunreachable-code]../../Modules/expat/xmlparse.c:7681:11: warning: format specifies type 'int' but the argument has type 'ptrdiff_t' (aka 'long') [-Wformat]../../Modules/socketmodule.c:4001:33: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]../../Modules/socketmodule.c:4054:33: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]../../Modules/socketmodule.c:4678:54: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare]

Error:

error: unable to open output file 'Modules/_testcapi/vectorcall.o': 'No such file or directory'

Maybe related to#93649?

@brandtbucher
Copy link
MemberAuthor

Maybe related to#93649?

Ah, yes, it is:#94549 (comment)

@brandtbucherbrandtbucher merged commit8a285df intopython:mainJul 9, 2022
@miss-islington
Copy link
Contributor

Thanks@brandtbucher for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 9, 2022
…94693)(cherry picked from commit8a285df)Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
@bedevere-bot
Copy link

GH-94699 is a backport of this pull request to the3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11only security fixes labelJul 9, 2022
Copy link
Contributor

@kumaraditya303kumaraditya303 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Post commit LGTM.

@tiran
Copy link
Member

Not sure why some of thewasm32 buildbots are failing, but it looks totally unrelated to these changes:

FYI, I have fixed the WASM buildbot issues in#94695. Once dependency was wrong and a directory was missing for OOT builds.

tiran pushed a commit to tiran/cpython that referenced this pull requestJul 9, 2022
…thonGH-94693)(cherry picked from commit8a285df)Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
kumaraditya303 pushed a commit to kumaraditya303/cpython that referenced this pull requestJul 9, 2022
miss-islington pushed a commit that referenced this pull requestJul 9, 2022
@brandtbucherbrandtbucher deleted the failed-call-cleanup branchJuly 21, 2022 19:52
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@pablogsalpablogsalpablogsal approved these changes

@kumaraditya303kumaraditya303kumaraditya303 left review comments

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

Assignees

@brandtbucherbrandtbucher

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@brandtbucher@bedevere-bot@miss-islington@tiran@pablogsal@kumaraditya303

[8]ページ先頭

©2009-2025 Movatter.jp