8000 GH-94739: Mark stacks in exception handlers. by markshannon · Pull Request #94958 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-94739: Mark stacks in exception handlers. #94958

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make it clearer that 0 == empty stack.
  • Loading branch information
markshannon committed Jul 18, 2022
commit 71342f1ec37aa7b505532075b0869057d2e6c571
8 changes: 5 additions & 3 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ compatible_kind(Kind from, Kind to) {
#define MAX_STACK_ENTRIES (63/BITS_PER_BLOCK)
#define WILL_OVERFLOW (1ULL<<((MAX_STACK_ENTRIES-1)*BITS_PER_BLOCK))

#define EMPTY_STACK 0

static inline int64_t
push_value(int64_t stack, Kind kind)
{
Expand All @@ -189,7 +191,7 @@ top_of_stack(int64_t stack)
static int64_t
pop_to_level(int64_t stack, int level) {
if (level == 0) {
return 0;
return EMPTY_STACK;
}
int64_t max_item = (1<<BITS_PER_BLOCK) - 1;
int64_t level_max_stack = max_item << ((level-1) * BITS_PER_BLOCK);
Expand Down Expand Up @@ -268,7 +270,7 @@ mark_stacks(PyCodeObject *code_obj, int len)
for (int i = 1; i <= len; i++) {
stacks[i] = UNINITIALIZED;
}
stacks[0] = 0;
stacks[0] = EMPTY_STACK;
if (code_obj->co_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR))
{
// Generators get sent None while starting:
Expand Down Expand Up @@ -373,7 +375,7 @@ mark_stacks(PyCodeObject *code_obj, int len)
stacks[i+1] = next_stack;
break;
case RETURN_VALUE:
assert(pop_value(next_stack) == 0);
assert(pop_value(next_stack) == EMPTY_STACK);
assert(top_of_stack(next_stack) == Object);
break;
case RAISE_VARARGS:
Expand Down
0