Skip to content

regcomp: handle cloning the rexc cleanup in the scope stack #23179

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 3 commits into from
Apr 19, 2025

Conversation

tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Apr 7, 2025

Previous on Win32 this could cause a double-free of the RExC state if an emulated fork was done with the free of the state on the scope stack.

Use a custom save type and prevent freeing in the cloned process to prevent the double-free.

Fixes #23022


  • This set of changes requires a perldelta entry, and it is included.

tonycoz added 3 commits April 19, 2025 17:09
Previous on Win32 this could cause a double-free of the RExC state if
an emulated fork was done with the free of the state on the scope
stack.

Use a custom save type and prevent freeing in the cloned process to
prevent the double-free.

Fixes Perl#23022
388bf71 (ignoring Perl#23022 for now) ensured that the RExC_state
and its controlled pointers were freed once and only once,
regardless of whether re_op_compile() returned normally or threw
an exception.

Unfortunately that free could happen very later, surviving well beyond
when the regexp was compiled.

Add an ENTER/LEAVE pair to ensure the cleanup is done immediately
on a normal return.
@mauke mauke force-pushed the 23022-pseudo-fork-rexc branch from e7c6b0a to c54f9ca Compare April 19, 2025 15:14
@mauke mauke merged commit 349f8f5 into Perl:blead Apr 19, 2025
33 checks passed
shawnlaffan added a commit to StrawberryPerl/Perl-Dist-Strawberry that referenced this pull request Apr 22, 2025
These are adapted from Perl/perl5#23179

Differences are:
1. The perldelta update is removed as it is 5.42 specific.
2. scope_types.h has been regenerated as its patch section did not apply cleanly.
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.

BBC: [WIN32] Blead breaks Error-0.17030
2 participants