Open
Description
Noticed when attempting to build with -Accflags='-DPERL_NO_COW'
$ ./Configure -des -Dusedevel -Accflags='-DPERL_NO_COW'
$ make -j8 miniperl
...
./miniperl -Ilib -f write_buildcustomize.pl
makefile:363: recipe for target 'lib/buildcustomize.pl' failed
make: *** [lib/buildcustomize.pl] Segmentation fault (core dumped)
Rebuilding with -DDEBUGGING shows an assertion failure:
$ ./Configure -des -Dusedevel -Accflags='-DPERL_NO_COW' -DDEBUGGING
$ make -j miniperl
...
./miniperl -Ilib -f write_buildcustomize.pl
miniperl: hv.c:2972: S_unshare_hek_or_pvn: Assertion `he->shared_he_he.hent_hek == hek' failed.
makefile:363: recipe for target 'lib/buildcustomize.pl' failed
Reducing to a minimal test case:
$ ./miniperl -wle 'my $x = (0 == 1);'
miniperl: hv.c:2972: S_unshare_hek_or_pvn: Assertion `he->shared_he_he.hent_hek == hek' failed.
Aborted (core dumped)
Bisecting points to commit 914bb57: (@leonerd)
commit 914bb57489325d34ddbb7c0557c53df7baa84d86
Author: Paul "LeoNerd" Evans <[email protected]>
Date: Sat Aug 7 14:46:48 2021 +0100
Define a third kind of COW state; STATIC
Previously, when IsCOW flag was set there were two cases:
SvLEN()==0:
PV is really a shared HEK
SvLEN()!=0:
PV is a COW structure with 1..256 refcount stored in its extra final byte
This change adds a third state:
SvLEN()==0 && SvFLAGS() & SVppv_STATIC:
PV is a shared static const pointer and must not be modified
sv_setsv_flags() and sv_setsv_cow() will preserve this state
sv_uncow() will copy it out to a regular string buffer
sv_dup() will preserve the static pointer into cloned threads
(Note: I have no use case for -DPERL_NO_COW
, I only tried it while looking at another issue)
Steps to reproduce
./Configure -des -Dusedevel -Accflags='-DPERL_NO_COW' -DDEBUGGING
make -j8 miniperl
./miniperl -wle 'my $x = (0 == 1);'
Actual result
Segmentation fault/Assertion failure:
S_unshare_hek_or_pvn: Assertion `he->shared_he_he.hent_hek == hek' failed.
Expected result
No crash.