Sunday, November 17

Perl DBI 1.50 bug in Weaken Support Check

0

A friends Ikonboard failed recently with an error saying:


Ikonboard has exited with the following error:

Modification of a read-only value attempted

The problem ended up being caused by a change in the DBI.pm module from 1.49 to 1.50.

The offending code is below:


275 # check for weaken support, used by ChildHandles
276 my $HAS_WEAKEN = eval {
277 require Scalar::Util;
278 # this will croak() if this Scalar::Util doesn't
have a working weaken().
279 Scalar::Util::weaken(my $test = "foo");
280 1;
281 };

The error is on line 279. The negates the " and instead of passing a reference to a scalar value to the weaken function, if returns something else, something that I assume can’t be modified by the weaken function, thus the error.

The code can be fixed by replacing the above code block with this one:


275 # check for weaken support, used by ChildHandles
276 my $HAS_WEAKEN = eval {
277 require Scalar::Util;
278 # this will croak() if this Scalar::Util doesn't
have a working weaken().
279 my $foo = "foo";
280 my $test = $foo;
281 Scalar::Util::weaken($test);
282 1;
283 };

 

Share.

Comments are closed.