Skip to content

class: don't leak the default initialiser ops if they're forbidden #21457

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 1 commit into from
Sep 14, 2023

Conversation

tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Sep 6, 2023

Previously if forbid_outofblock_ops() here threw an error the ops from defop would leak, including leaking the slab(s) containing those ops.

The other callers to forbid_outofblock_ops() left the ops being checked on the parser stack when performing this check, so the parse stack clean up would release the ops, but the field initaliser code removes the OP from the parse stack before
class_set_field_defop() so the OP and its children leaked.

To prevent that, populate the defop for the field with the supplied ops before calling forbid_outofblock_ops(), then as the stack rewinds class_seal_stash() will check the error count and free the ops.

Fixes #20812

@tonycoz tonycoz requested a review from leonerd September 6, 2023 00:41
Previously if forbid_outofblock_ops() here threw an error the ops
from defop would leak, including leaking the slab(s) containing
those ops.

To prevent that, populate the defop for the field with the supplied ops
before calling forbid_outofblock_ops(), then as the save stack rewinds
class_seal_stash() will check the error count and free the ops.

Fixes Perl#20812
@tonycoz tonycoz force-pushed the 20812-class-forbid-ops-leak branch from 3b506eb to 02c610a Compare September 7, 2023 00:00
Copy link
Contributor

@leonerd leonerd left a comment

Choose a reason for hiding this comment

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

LGTM

@tonycoz tonycoz merged commit 080297a into Perl:blead Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature 'class' appears to leak opslabs
2 participants