stack space full (SEGFAULT) when accessing %hash with undefined $var (use warnings)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
perl (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Accessing a hash entry with an undefined variable as key causes infinite recursion and running out of stack space. This only happens when '-w' ("use warnings;") is enabled.
Steps to reproduce:
$ perl -e 'my %hash = (); int($hash{
(no crash)
$ perl -we 'my %hash = (); int($hash{
Useless use of int in void context at -e line 1.
Name "main::
Use of uninitialized value $undefined_var in hash element at -e line 1.
Segmentation fault
Version: perl-base (5.34.0-3ubuntu1.2) on Jammy
Backtrace (after installing perl-debug):
Program received signal SIGSEGV, Segmentation fault.
0x00005555556
350 in /build/
(gdb) bt 10
#0 0x0000555555652d1d in Perl_hv_common (
my_
keysv=
action=0, val=0x0, hash=0)
at /build/
#1 0x0000555555684afc in S_find_uninit_var (
my_
uninit_
desc_
at /build/
#2 0x0000555555684ce4 in Perl_report_uninit (
my_
at /build/
#3 0x000055555566771d in Perl_sv_2pv_flags (
my_
lp=
at /build/
#4 0x0000555555652fd5 in Perl_hv_common (
my_
keysv=
flags=
hash=
at /build/
#5 0x0000555555684afc in S_find_uninit_var (
my_
uninit_
desc_
at /build/
#6 0x0000555555684ce4 in Perl_report_uninit (
my_
at /build/
#7 0x000055555566771d in Perl_sv_2pv_flags (
my_
lp=
at /build/
#8 0x0000555555652fd5 in Perl_hv_common (
my_
keysv=
flags=
hash=
at /build/
#9 0x0000555555684afc in S_find_uninit_var (
my_
uninit_
desc_
at /build/
(More stack frames follow...)
Long backtrace:
#0 0x0000555555652d1d in Perl_hv_common (my_perl=..., hv=..
#1 0x0000555555684afc in S_find_uninit_var (my_perl=..., ob
#2 0x0000555555684ce4 in Perl_report_uninit (my_perl=..., u
#3 0x000055555566771d in Perl_sv_2pv_flags (my_perl=..., sv
#4 0x0000555555652fd5 in Perl_hv_common (my_perl=..., hv=..
#5 0x0000555555684afc in S_find_uninit_var (my_perl=..., ob
#6 0x0000555555684ce4 in Perl_report_uninit (my_perl=..., u
#7 0x000055555566771d in Perl_sv_2pv_flags (my_perl=..., sv
#8 0x0000555555652fd5 in Perl_hv_common (my_perl=..., hv=..
#9 0x0000555555684afc in S_find_uninit_var (my_perl=..., ob
...
#67607 0x000055555566771d in Perl_sv_2pv_flags (my_perl=...,
#67608 0x0000555555652fd5 in Perl_hv_common (my_perl=..., hv
#67609 0x0000555555684afc in S_find_uninit_var (my_perl=...,
#67610 0x0000555555684ce4 in Perl_report_uninit (my_perl=...
#67611 0x000055555566524a in Perl_sv_2iv_flags (my_perl=...,
#67612 0x000055555568e21d in Perl_pp_int (my_perl=...)
#67613 0x000055555564fac6 in Perl_runops_
#67614 0x00005555555c955c in S_run_body (oldscope=..., my_pe
#67615 perl_run (my_perl=...)
#67616 0x000055555559e977 in main (argc=..., argv=..., env=.
Cheers!
Walter Doekes
OSSO B.V.
On Tue, Aug 22, 2023 at 02:28:18PM -0000, Walter wrote:
> Accessing a hash entry with an undefined variable as key causes infinite
> recursion and running out of stack space. This only happens when '-w'
> ("use warnings;") is enabled.
This is https:/ /github. com/Perl/ perl5/issues/ 19147 , broken around 5.33.1
and fixed around 5.35.5 with
https:/ /github. com/Perl/ perl5/commit/ 23cca2d1f4544cb 47f1124d98c308c e1f31f09a6
Hope this helps somebody fix this in Ubuntu. Debian is not affected as we
never shipped 5.34 in a stable release.
--
Niko Tyni <email address hidden>