Skip to content

Conversation

@tonycoz
Copy link
Contributor

@tonycoz tonycoz commented Jan 23, 2023

pp_select() ensures that the GV in PL_defoutgv has an IO object when it the default output is set, but can't prevent that GV being cleared afterwards, resulting in a seg fault when the variable is written.

To prevent this, check PL_defoutgv has an IO object before trying to write to it.

Fixes #20733

pp_select() ensures that the GV in PL_defoutgv has an IO object
when it the default output is set, but can't prevent that GV
being cleared afterwards, resulting in a seg fault when the
variable is written.

To prevent this, check PL_defoutgv has an IO object before trying
to write to it.

Fixes Perl#20733
@jkeenan
Copy link
Contributor

jkeenan commented Jan 24, 2023

Following a TDD approach, I applied a patch of t/io/defout.t only to blead and ran the test program. It failed due to segfault. I then tested the branch; make test_harness PASSed.

LGTM, but someone with more C-foo should review the changes to mg.c.

@tonycoz tonycoz merged commit af62106 into Perl:blead Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

writing to magic variables connected to the selected output GV when its IO object has been cleared crashes perl

3 participants