-
Notifications
You must be signed in to change notification settings - Fork 584
Clean up PL_strtab hash with NULL in perl_destruct #23346
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
base: blead
Are you sure you want to change the base?
Clean up PL_strtab hash with NULL in perl_destruct #23346
Conversation
Since your pull request is intended to correct a possible segfault, can you supply the output of |
The output of `perl -V`:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this makes sense to me.
Ironically I think it's only a problem on non-multiplicity perls (on multiplicity the perl struct is allocated and null initialized.
For non-MULTIPLICITY builds I suspect the real fix here is to zero |
Crash happens when perl is compiled with libFuzzer in a program like this: fuzz.c
Compiled with compilation commands
When pre-initialized with NULL, there is no crash. |
Emphasis added and marking ticket "Release Blocker." |
Yes, you're running the interpreter multiple times. The first time around The second time around If I test with code like:
I get the same type of crash you did without ASAN or a fuzzer:
(I get a Segmentation fault without valgrind too.) If I clear Adding an initializer to the |
a1c407c
to
3d7f78a
Compare
Finally, I've got it. |
3d7f78a
to
0ad853a
Compare
This has been around for much longer than just this release. That doesn’t meant we wouldn’t very much like to ship a fix in this release… once it becomes clear what the right fix is. |
I think the current change is ok, though using github to merge blead (I assume from the email address and history) broke the authors porting test. @antirs, please rebase on blead and squash your commits, this should remove the merge and make it ready to apply. |
fa688c7
to
2345cf0
Compare
As it's not required to pre-allocate PL_strtab hash before perl_construct() and PL_strtab is not initialized with NULL by default, SIGSEGV could happen in certain circumstances. Particularly, when application links libperl and runs perl several times. After the first run PL_strtab remains unitialized in perl_construct() as it was not cleared in perl_destruct() and it contains garbage and the next initialization in perl_construct() is skipped because !PL_strtab check is skipped. See also: c82f488 (Allow custom PL_strtab hash in perl_construct.)
2345cf0
to
87c0504
Compare
As it's not required to pre-allocate PL_strtab hash before perl_construct() and PL_strtab is not initialized with NULL by default, SIGSEGV could happen in certain circumstances.
Particularly, when application links libperl and compiled with ASAN. PL_strtab remains unitialized as at start-up it contains garbage and initialization in perl_construct() is skipped because !PL_strtab check is skipped.
See also: c82f488 (Allow custom PL_strtab hash in perl_construct.)
Crash log may look like this: