f.zz.de
posts /

Segfault perl with Clone::clone

Posted Thu Oct 12 18:48:32 2023 Florian Lohoff
in

Interesting - Using clone on a datastructure containing a ref to a dbh e.g. result from DBI->connect and using that ref from the cloned object lets perl segfault:

Short form:

$dbh=DBI->connect(...);
$a={ dbh => $dbh };
$b=Clone::clone($a);
$b->{dbh}->prepare(...)

gdb backtrace shows:

(gdb) bt
#0  0x00007f409c5e387b in XS_DBI_dispatch () from /usr/lib/x86_64-linux-gnu/perl5/5.36/auto/DBI/DBI.so
#1  0x0000561f3f0a5f18 in Perl_pp_entersub ()
#2  0x0000561f3f09bef6 in Perl_runops_standard ()
#3  0x0000561f3effa779 in perl_run ()
#4  0x0000561f3efcc4b2 in main ()