Branch: refs/heads/yves/fix_19350
  Home:   https://github.com/Perl/perl5
  Commit: c982e5305bf97f6f62a29053c7bbcb76e9649c44
      
https://github.com/Perl/perl5/commit/c982e5305bf97f6f62a29053c7bbcb76e9649c44
  Author: Yves Orton <[email protected]>
  Date:   2022-01-24 (Mon, 24 Jan 2022)

  Changed paths:
    M regcomp.c

  Log Message:
  -----------
  Fixup Issue #19350 - Assert error under: use re Debug=>"ALL" (or "PARSE")

In 7c932d07cab18751bfc7515b4320436273a459e2 karl changed the regex parser
to not do two passes always, and instead do one if it could. However in
some edge cases it still must do a second past and some of the info needed
for the Debug => "All" would not be available during the first pass.

This was compounded by S_add_data() validly returning a 0 index for
data that was stored in the data array, which meant that there was no
way to tell the difference between "we dont have the data to call S_add_data()
at all" and "we called S_add_data() and it returned 0", this in turn
would cause the dumping logic to try to access data that was not there,
and misinterpret it as a valid SV, with ensure assert fails or worse
segfaults.

This patch changes S_add_data() so it always returns a non-zero
return, so that the regex debug logic can tell that it shouldnt do
a lookup into the data array. This means create a new "what" type
of "%", which is used SOLELY to populate the ->data[0] and ->what[0]
with a dummy entry.

With this done we can add guard statements to places that lookup
things in the data array, if the index is 0 it can not be valid.


  Commit: a1fc433584d56e1ea0aff0f3c41e0930cb95f4a2
      
https://github.com/Perl/perl5/commit/a1fc433584d56e1ea0aff0f3c41e0930cb95f4a2
  Author: Yves Orton <[email protected]>
  Date:   2022-01-24 (Mon, 24 Jan 2022)

  Changed paths:
    M t/re/pat_advanced.t

  Log Message:
  -----------
  Tests for Issue #19350, assert fail with Debug=>ALL

Note that 'use re Debug => "ALL"' and 'use re Debug => "PARSE"'
are basically the same as far as this issue goes. ALL implies PARSE
along with other things, the fault is in how the PARSE part works,
and the omitting the full output of ALL and just testing PARSE is
sufficient to test this issue, and avoids any need to deal with
memory addresses or word size issues that are irrelevant to the
issue anyway.


Compare: https://github.com/Perl/perl5/compare/70486f438fc8...a1fc433584d5

Reply via email to