Skip to content

Conversation

@tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Dec 3, 2023

Prior to this commit when producing a warning the regexp compiler would check if the warning category was marked as FATAL, and if it was it would add clean up to the save stack to release buffers used during compilation and to release the working REGEXP SV.

This causes two type of problems:

  • if an error was already queued, Perl_ck_warner() returns even if the warning is fatal, this meant that the normal clean up code Perl_re_op_compile() would also run, resulting in a double free of the buffers.

  • without fatal warnings, if a $SIG{WARN} handler died, the buffers and the working REGEXP SV would leak.

Avoid this by using SAVEDESTRUCTOR_X() to release the memory and optionally the SV at the end of scope.

Fixes #21661

@tonycoz tonycoz force-pushed the smoke-me/tonyc/21661-no-warn-ck branch from 72efebc to 2016cd1 Compare February 22, 2024 03:54
@demerphq
Copy link
Collaborator

demerphq commented Mar 7, 2024

@tonycoz looks like this can be merged?

@jkeenan jkeenan added the Closable? We might be able to close this ticket, but we need to check with the reporter label Aug 3, 2024
@jkeenan
Copy link
Contributor

jkeenan commented Aug 3, 2024

@tonycoz, this p.r. has had merge conflicts for close to 5 months. Do you intend to go forward with it? If not, please consider closing it. Thanks.

tonycoz added 4 commits August 3, 2024 13:28
Prior to this commit when producing a warning the regexp compiler
would check if the warning category was marked as FATAL, and if it was
it would add clean up to the save stack to release buffers used during
compilation and to release the working REGEXP SV.

This causes two type of problems:

- if an error was already queued, Perl_ck_warner() returns even if
  the warning is fatal, this meant that the normal clean up code
  Perl_re_op_compile() would also run, resulting in a double free
  of the buffers.

- without fatal warnings, if a $SIG{__WARN__} handler died, the
  buffers and the working REGEXP SV would leak.

Avoid this by using SAVEDESTRUCTOR_X() to release the memory and
optionally the SV at the end of scope.

Fixes #21661
These can be simpler, and since we allow use of __VA_ARGS__
we can consolidate Simple_vFAIL[1-4]() into Simple_vFAILn()
We are now always prepared for death.
@mauke mauke force-pushed the smoke-me/tonyc/21661-no-warn-ck branch from 2016cd1 to ce34730 Compare August 3, 2024 11:58
@mauke mauke removed the hasConflicts label Aug 3, 2024
@mauke
Copy link
Contributor

mauke commented Aug 3, 2024

I've rebased the PR on top of blead and removed the conflicts. Unless someone objects (or beats me to the punch), I intend on merging this within a day or two.

@mauke mauke merged commit eb62f8d into blead Aug 4, 2024
@mauke mauke deleted the smoke-me/tonyc/21661-no-warn-ck branch August 4, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Closable? We might be able to close this ticket, but we need to check with the reporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

double free or corruption (fasttop) during compilation phase on Perl one liner

6 participants