develooper Front page | perl.perl5.porters | Postings from July 2016

Re: [perl #128597] SEGV caused by isLEXWARN_off while PL_curcop isNULL(gp_free vs dounwind).

Thread Previous | Thread Next
From:
Zefram
Date:
July 11, 2016 20:14
Subject:
Re: [perl #128597] SEGV caused by isLEXWARN_off while PL_curcop isNULL(gp_free vs dounwind).
Message ID:
20160711201443.GN1170@fysh.org
Father Chrysostomos via RT wrote:
>Then $fh is freed, which tries to check the warning flags, but I don't
>know why.

The added code in gv.c checks whether I/O warnings are enabled as part
of deciding whether to try closing a writable I/O handle.  The test case
also depends on the handle being writable; if opened in "<" mode then it
doesn't crash.  The check of the warning is done via ckWARN_d(WARN_IO),
which is implemented by ckwarn_d(), which tests isLEXWARN_off, which
dereferences PL_curcop without checking for nullness.

>It also does not explain why the eval is necessary.

Without it, the sub is additionally referenced by the anoncode op in the
main program, so the cop isn't freed that early.  With string eval the
equivalent anoncode op is in the temporary code generated by the eval,
which will be freed on unwind.

>I suspect any warning that can happen during freeing could result in
>a similar crash.  (Are there any other such warnings?)

Good question.  I'd also like to question why the I/O closure warning
is being checked against the lexical warning flags of a place that is no
longer executing and doesn't have any real connection to the I/O handle.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About