Commit 8993af9
committed
make pregexec() handle zero-length strings again
GH #23903
In embed.fnc, commit v5.43.3-167-g45ea12db26 added SPTR, EPTR parameter
modifiers to (amongst other API functions), Perl_pregexec().
These cause assert constraints to be added to the effect that SPTR <
EPTR (since the latter is supposed to be a pointer to the byte after the
last character in the string).
This falls down for an empty string since in this case pregexec() is
called with strbeg == strend.
This was causing an assert failure in the test suite for
Package-Stash-XS.
The reason it wasn't noticed before is because:
1) pregexec() is a thin wrapper over regexec_flags();
2) The perl core (e.g. pp_match()) calls regexec_flags() rather than
pregexec();
3) Package::Stash::XS has XS code which calls pregexec() directly rather
than using CALLREGEXEC() (which would call regexec_flags());
4) In embed.fnc, regexec_flags()'s strend parameter is declared as
NN rather than EPTR, so it doesn't get the assert added.
So very little code was actually using pregexec().
This commit, for now, changes pregexec()'s strend parameter from EPTR to
EPTRQ, which has the net effect of allowing zero-length strings to be
passed, and thus fixes the CPAN issue.
But longer term, we need to decide: is the general logic for EPTR wrong?
Should the assert be SPTR <= EPTR? And should EPTR be applied to
regexec_flags()'s strend parameter too?1 parent c8c2426 commit 8993af9
File tree
5 files changed
+31
-5
lines changed- ext/XS-APItest
- t
5 files changed
+31
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2713 | 2713 | | |
2714 | 2714 | | |
2715 | 2715 | | |
2716 | | - | |
| 2716 | + | |
2717 | 2717 | | |
2718 | 2718 | | |
2719 | 2719 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4780 | 4780 | | |
4781 | 4781 | | |
4782 | 4782 | | |
| 4783 | + | |
| 4784 | + | |
| 4785 | + | |
| 4786 | + | |
| 4787 | + | |
| 4788 | + | |
| 4789 | + | |
| 4790 | + | |
| 4791 | + | |
| 4792 | + | |
| 4793 | + | |
| 4794 | + | |
| 4795 | + | |
| 4796 | + | |
| 4797 | + | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
| 4805 | + | |
4783 | 4806 | | |
4784 | 4807 | | |
4785 | 4808 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| 67 | + | |
65 | 68 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments