Commit
9ffd39ab75, which allowed PADTMPs’ string buffers to be stolen,
caused "$a$b" =~ /(??{})/ to cause string corruption with match varia-
bles on some systems, because the buffer from "$a$b"’s return value
was being stolen when ‘copied’ into a new $_ for the code block.
The string copy necessary for $& and $1 to work would happen only
after the code block’s $_ had been freed, and consequently after the
string buffer had been freed.
Whether this would cause observable buggy behaviour (as opposed to
things only memory tools like valgrind would catch) depended on
whether the malloc implementation would modify the string immediately
when freeing it.
Dave Mitchell observed in <
20131218113448.GN2490@iabyn.com> that tests
were failing under -DPERL_NO_COW. The added test will also fail (for
me at least) under copy-on-write, because the string is long enough to
favour swiping the buffer. (It happens for me only on Linux, not Dar-
win, incidentally.)
Copying the string with _nosteal fixes the problem.