-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
charnames and \p or \N regex SEGV in SWASHNEW >5.22 #273
Comments
What I think is happening is that perl tries to autoload some modules when it sees \p in a regex. The fact that _charnames is already there causes it confusion and thus the segfault. While this is a very convoluted example, simply using the module charnames qw/:full/ is enough to set this problem off. Probably we need some sort of special handling during compile to handle this properly. What's interesting is that \p does not seem to trigger _charnames $>perl -e'my $regex = qr/\p{foo}/; print join("\n", sort keys %INC)'
XSLoader.pm
re.pm
strict.pm
unicore/Heavy.pl
utf8.pm
utf8_heavy.pl |
Also note, this was triggered by changing the stash walk into a reverse sort rather than a sort in commit e33aec3. This probably means some special global when walked will trigger the load of certain stashes (modules) automajically. It also means we probably bloated our binaries with the above modules because of it. |
We can probably just keep an eye on this until we have a practical case where this comes up. |
This will cause a segfault: Unfortunately while not much on CPAN uses \p, much more uses \N. Locale::Maketext::Utils included. |
#266 was closed as a duplicate of this case |
./t/testc.sh 273 |
SEGV in utf8 SWASHNEW:
|
No, it's not a method bug related to #298. It's a missing GV in a multideref. |
Looks like this is coming from the PL_hintgv once referenced in one UNOP_AUX list idea: diff --git a/lib/B/C/OverLoad/B/UNOP_AUX.pm b/lib/B/C/OverLoad/B/UNOP_AUX.pm
index d438139..36bc26e 100644
--- a/lib/B/C/OverLoad/B/UNOP_AUX.pm
+++ b/lib/B/C/OverLoad/B/UNOP_AUX.pm
@@ -80,9 +80,12 @@ sub save {
}
}
else {
- # gv or other late inits
- $s .= "\t,{.sv=Nullsv} \t/* $itemsym */\n";
- init2()->add("unopaux_item${ix}[$i].sv = (SV*)$itemsym;");
+ if ( $itemsym =~ qr{^PL_} ) {
+ $s .= "\t,{.sv=((SV* const) \&$itemsym)} \t/* $itemsym */\n";
+ } else {
+ $s .= "\t,{.sv=Nullsv} \t/* $itemsym */\n";
+ init2()->add("unopaux_item${ix}[$i].sv = (SV*)$itemsym;");
+ }
}
}
$i++; gdb output
|
Here is a sample of a UNOP_AUX where we can notice the problem, Looks like we should point to the second element (ix=1), the GV here and not the flag |
This needs unop_aux deferred GV symbols being defined already. Fixes GH #273, t/testc.sh 273 2731
No, it's only a timing problem. The regexp compiler is called in init, but the symbol is only set at init2.
This was not enough, as dl_init already needs some compiled regex, split in load_file. See 9ebc799 and 82ba15b So I had to add a new section $init1. This is complicated by the fact the calling utf8::SWASHNEW itself already needs some compiled regexp, which need to be initialized already, similar to XSLoader::load_file. Done in 6e456de |
This needs unop_aux deferred GV symbols being defined already. Fixes GH #273, t/testc.sh 273 2731 new deferred init1 section before dl_init dl_init needs some regexes already setup, split in load_file protect dlsym init2 code from being split. move some init2 parts (after dl_init) to init or init1, which might be needed for the regex compiler. We have have to do both, immediate PMOP::save for simple regex without needing SWASHNEW init, and deferred for regex which do a SWASHNEW. The problem is that some regex need to be present earlier, e.g. XSLoader::load_file has a split, SWASHNEW itself uses some regex. So we need to save them in $init, but need to defer others, esp. those needed multideref GVs, such as in SWASHNEW to later. Also pass down the B::OP::save $level argument, which was prev. ignored. And accept some optional $fullname args, which are rarely used. Also do now static init of op_pmreplstart
Fixed with cbc7f1f |
This needs unop_aux deferred GV symbols being defined already. Fixes GH rurban#273, t/testc.sh 273 2731 new deferred init1 section before dl_init dl_init needs some regexes already setup, split in load_file protect dlsym init2 code from being split. move some init2 parts (after dl_init) to init or init1, which might be needed for the regex compiler. We have have to do both, immediate PMOP::save for simple regex without needing SWASHNEW init, and deferred for regex which do a SWASHNEW. The problem is that some regex need to be present earlier, e.g. XSLoader::load_file has a split, SWASHNEW itself uses some regex. So we need to save them in $init, but need to defer others, esp. those needed multideref GVs, such as in SWASHNEW to later. Also pass down the B::OP::save $level argument, which was prev. ignored. And accept some optional $fullname args, which are rarely used. Also do now static init of op_pmreplstart (cherry picked from commit cbc7f1f) Signed-off-by: Nicolas Rochelemagne <rochelemagne@cpanel.net>
This needs unop_aux deferred GV symbols being defined already. Fixes GH rurban#273, t/testc.sh 273 2731 new deferred init1 section before dl_init dl_init needs some regexes already setup, split in load_file protect dlsym init2 code from being split. move some init2 parts (after dl_init) to init or init1, which might be needed for the regex compiler. We have have to do both, immediate PMOP::save for simple regex without needing SWASHNEW init, and deferred for regex which do a SWASHNEW. The problem is that some regex need to be present earlier, e.g. XSLoader::load_file has a split, SWASHNEW itself uses some regex. So we need to save them in $init, but need to defer others, esp. those needed multideref GVs, such as in SWASHNEW to later. Also pass down the B::OP::save $level argument, which was prev. ignored. And accept some optional $fullname args, which are rarely used. Also do now static init of op_pmreplstart (cherry picked from commit cbc7f1f) Signed-off-by: Nicolas Rochelemagne <rochelemagne@cpanel.net> Author: Reini Urban <rurban@cpanel.net> Date: Tue Nov 3 23:30:33 2015 +0100 C: fix uninitialized value $level warnings (cherry picked from commit 9970b03) adjust known_errors from swash branch
This needs unop_aux deferred GV symbols being defined already. Fixes GH rurban#273, t/testc.sh 273 2731 new deferred init1 section before dl_init dl_init needs some regexes already setup, split in load_file protect dlsym init2 code from being split. move some init2 parts (after dl_init) to init or init1, which might be needed for the regex compiler. We have have to do both, immediate PMOP::save for simple regex without needing SWASHNEW init, and deferred for regex which do a SWASHNEW. The problem is that some regex need to be present earlier, e.g. XSLoader::load_file has a split, SWASHNEW itself uses some regex. So we need to save them in $init, but need to defer others, esp. those needed multideref GVs, such as in SWASHNEW to later. Also pass down the B::OP::save $level argument, which was prev. ignored. And accept some optional $fullname args, which are rarely used. Also do now static init of op_pmreplstart (cherry picked from commit cbc7f1f) Signed-off-by: Nicolas Rochelemagne <rochelemagne@cpanel.net> Author: Reini Urban <rurban@cpanel.net> Date: Tue Nov 3 23:30:33 2015 +0100 C: fix uninitialized value $level warnings (cherry picked from commit 9970b03) adjust known_errors from swash branch
I cannot simplify this code much more than this but I think the code I have shows the problem sufficiently:
If you change the package name to anything else or remove \p from the regex, the program will not fail.
The text was updated successfully, but these errors were encountered: