Segfault w/ Clone/DBI

Florian Lohoff <[email protected]>
Newsgroups gmane.linux.debian.devel.perl
Organization rfc822 - pure communication
Message-ID <[email protected]>
Hi,
i am pretty shure this is a known side effect of Clone but still i am a
bit impressed. Short form:

This segfaults on the ->prepare call.

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

gdb backtrace is:

(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 ()

Replacing the Clone::clone with 

	foreach my $k ( keys %{$a} ) {
		$b->{$k}=$a->{$k};
	}

Makes the segfault disappear. So it seems Clone trys to make a deep copy
of some XS object which on usage segfaults horribly. I would have
expected it to only copy the reference to the DBI/DBH object.

This is all stock Debian/Bookworm using postgresql.

Flo
-- 
Florian Lohoff                                                     [email protected]
  Any sufficiently advanced technology is indistinguishable from .
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEdb9o7oebX2papQ/KkN1BIMsJ8i8FAmUoJpMACgkQkN1BIMsJ
8i9Z7A//fLBfnlGDcSevSid+X48+7+r55qs8/2qmDYGwdukWZHkapB90XiRQhLT3
kaoFbwWitgE+bJvuJK7aMrQgFi4Tv23OvhJMtL+TV8pOgJP09taCxLwFn62GmHMu
VVB8nGJH2XURkap+fXpxSs9gqnp/RoKp3Eg7VVeHdSB65HY05I/ksraPTGxJQuIn
Br5R4p7RutRMPpoVpqiToOT3a0RBVDt8JQmD+N5V/p1iQ8+bAr3K5WZLatfsxx9b
yq8/A3kHcUfuPchuq6/0yACis51VBawyVzAIbgHJ1xtA4OdVtudoqDY5tbIOjLWg
rHtIcMPDMnKrdk03ObqC9f1v8XhY+Mg8721cIMdxDrM/VtZzTQgWGkJOrAsUVxEK
lYl3e+LXGLtiTrpegHN6IAJtv+l1NIm8Sfvx/OmZVS+n6Myb2pxDzqJw+DdUOzt2
ctb8uPp1SV50ggrpk2HMtuED2pKu0YMQMusTBRo+2/yxl/imJiGKuV7GcWP5x319
Rqoxlkx7OrhT+cLXYlY44Vq3GyxLe7qGK8ud6QJ5KjMEkp3/yA/oIiAyVsUzP07+
BDghrDeFaPOzlyPlHfodEsl/hrMMUB8n1WVPkBApZlxn2pS+JXbjXzE6iuJscYbd
C8WU/59NruGnX24lnLdzKnr6rW9RiwECdmZAP6TVkvRrClr9WVw=
=0ufF
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.