Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsal pablogsal commented May 8, 2019

https://bugs.python.org/issue36851

When evaluating a frame object, it is possible to exit the execution with some variables in the stack. The frame deallocator (frame_dealloc) only cleans the stack if f_stacktop is not NULL, but this only happens for generators and when trace functions are set. The eval loop does this cleanup already if an exception is being raised, but not if a RETURN_VALUE is set.

In the PyconUS sprints, @DinoV and I have been working on this and we have decided that the cleanest approach is shared the same goto label with the path for exception handling, effectively cleaning up

@pablogsal pablogsal requested a review from DinoV May 8, 2019 15:43
@pablogsal pablogsal changed the title bpo-36851 :Clean the frame stack if the execution ends with a return and the stack is not empty bpo-36851: Clean the frame stack if the execution ends with a return and the stack is not empty May 8, 2019
@pablogsal pablogsal force-pushed the clean_stack branch 2 times, most recently from 9cda466 to 2d0a4e8 Compare May 8, 2019 15:47
@pablogsal pablogsal self-assigned this May 8, 2019
@DinoV
Copy link
Contributor

DinoV commented May 8, 2019

This looks good to me!

@pablogsal pablogsal merged commit f00828a into python:master May 9, 2019
@pablogsal pablogsal deleted the clean_stack branch May 9, 2019 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4 participants