Bus error -- Re: [mapserver-users] Re: Perl/mapscript error
Giorgio Volpe
giorgio at nauta.it
Tue Apr 30 12:10:49 PDT 2002
Lowell Filak wrote:
>
> Giorgio - which DESTROY subroutine did you insert your print statement into, mapObj, layerObj, classObj, ...? It looks like layerObj as opposed to mapObj where Puneet is having trouble.
> Lowell F.
I have the same problem with many different objects!
It happened with rectObj, layerObj, classObj for eample ... never with
mapObj.
I'inserted my "debug" print before the line suggested in the error
message ...
I observed that:
- the object being tied is a scalar, and this is why the destructor is
called twice (i immagine !) one for the original variable and the other
for the "tied" virtual variable
- Not always the call to the destructor with a scalar value causes the
error!
- The problem seems connected to the use of a variable to store a
reference to an object. If I undef that variable the error disappears
(also if i have the same output in my debug ... see attached code ...)
- In some case the same code works perfectly !!! (as says Lowell this
suggest that the error is somewere else ... but I can't find it!!!)
by
Giorgio
----------------------------------------------------------------------
Here my "shenanigans" ... with rectObj
Modified DESTROY as:
(/usr/local/lib/perl/5.6.1/mapscript.pm line 1801)
sub DESTROY {
print STDERR "==== destroing: $_[0]\n"; #ADDED LINE
my $self = tied(%{$_[0]});
delete $ITERATORS{$self};
Modified "constructor" TIEHASH (in "father" package) as :
(/usr/local/lib/perl/5.6.1/mapscript.pm line 16)
package mapscript;
sub TIEHASH {
my ($classname,$obj) = @_;
print STDERR "==== Tieing: $classname,$obj\n"; #ADDED LINE
return bless $obj, $classname;
}
Now execute ...
sub ext_map {
my $me=shift;
my $mappa=$me->map(); # Here I've saved my map
print STDERR ">>>>>> Start some debugging :-<\n";
print STDERR ">>>>>> map->extent is: ".$map->{extent}."\n";
print STDERR ">>>>>> now let's assign my \$ext=\$map->{extent}\n";
my $ext=$map->{extent};
print STDERR ">>>>>> my var ext is: $ext \n";
return;
}
This is the output in the error LOG!!!
>>>>>> Start some debugging :-<
==== Tieing: rectObj,rectObj=SCALAR(0x846f1a8)
>>>>>> map->extent is: rectObj=HASH(0x8472c84)
==== destroing: rectObj=HASH(0x8472c84)
==== destroing: rectObj=SCALAR(0x846f1a8)
>>>>>> now let's assign my $ext=$mappa->{extent}
==== Tieing: rectObj,rectObj=SCALAR(0x84917c0)
>>>>>> my var ext is: rectObj=HASH(0x84916dc)
==== destroing: rectObj=HASH(0x84916dc)
==== destroing: rectObj=SCALAR(0x84917c0)
ERROR: (in cleanup) Not a HASH reference at
/usr/local/lib/perl/5.6.1/mapscript.pm line 1805.
NB:
The error rise before return from sub to the caller.
If I add "undef $ext" before "return" the error disappears!
Other test ...
Tring dumping the data before destroing ... all seems ok
data are there, object is not silently "gone".
added in DESTROY
use Data::Dumper;
print STDERR Dumper($_[0])."\n===========================\n";
OUTPUT:
>>>>>> Start some debugging :-<
==== Tieing: rectObj,rectObj=SCALAR(0x8448714)
>>>>>> map->extent is: rectObj=HASH(0x8491274)
==== destroing: rectObj=HASH(0x8491274)
$VAR1 = bless( {
'minx' => '1811107',
'miny' => '5060718',
'maxx' => '1818823',
'maxy' => '5062904'
}, 'rectObj' );
===========================
==== destroing: rectObj=SCALAR(0x8448714)
$VAR1 = bless( do{\(my $o = 139117832)}, 'rectObj' );
===========================
>>>>>> now let's assign my $ext=$mappa->{extent}
==== Tieing: rectObj,rectObj=SCALAR(0x84b0de4)
>>>>>> my var ext is: rectObj=HASH(0x84b0300)
==== destroing: rectObj=HASH(0x84b0300)
$VAR1 = bless( {
'minx' => '1811107',
'miny' => '5060718',
'maxx' => '1818823',
'maxy' => '5062904'
}, 'rectObj' );
===========================
==== destroing: rectObj=SCALAR(0x84b0de4)
$VAR1 = bless( do{\(my $o = 139117832)}, 'rectObj' );
===========================
!!! Same output when it's ok or when error!
More information about the MapServer-users
mailing list