[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Segfault w/ Clone/DBI



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                                                     f@zz.de
  Any sufficiently advanced technology is indistinguishable from .

Attachment: signature.asc
Description: PGP signature


Reply to: