| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality⚠️ Potential issue | 🟠 Major
Use the runtime closure length when sizing datastack frames.
Frame::new() sizes localsplus with closure.len(), but this helper hard-codes code.freevars.len(). Since set___code__ still allows swapping in a code object without revalidating the stored closure, callers that reserve datastack space via this helper can compute a smaller layout than prepare_exact_args_frame() will actually allocate.
Possible directionpub(crate) fn datastack_frame_size_bytes(&self) -> Option<usize> { - datastack_frame_size_bytes_for_code(&self.code) + datastack_frame_size_bytes_for_layout( + &self.code, + self.closure.as_ref().map_or(0, |c| c.len()), + ) } -pub(crate) fn datastack_frame_size_bytes_for_code(code: &Py<PyCode>) -> Option<usize> { +pub(crate) fn datastack_frame_size_bytes_for_layout( + code: &Py<PyCode>, + nfrees: usize, +) -> Option<usize> { if code .flags .intersects(bytecode::CodeFlags::GENERATOR | bytecode::CodeFlags::COROUTINE) { return None; } let nlocalsplus = code .varnames .len() .checked_add(code.cellvars.len())? - .checked_add(code.freevars.len())?; + .checked_add(nfrees)?; let capacity = nlocalsplus.checked_add(code.max_stackdepth as usize)?; capacity.checked_mul(core::mem::size_of::<usize>()) }Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.