Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#1707 closed defect (wontfix)

perl GDAL swig interface requires "undef" call to successfully write output to image file

Reported by: westside Owned by: Ari Jolma
Priority: normal Milestone:
Component: default Version: unspecified
Severity: normal Keywords:
Cc: warmerdam, hobu

Description

See the attached simple perl script. The output GTiff is incorrect unless you force the delete of the datasource by calling undef in perl on the dataset variable.

I'm using GDAL 1.4.0

Attachments (1)

test_bw3.pl (841 bytes ) - added by westside 17 years ago.
perl script that demonstrates the problem

Download all attachments as: .zip

Change History (5)

by westside, 17 years ago

Attachment: test_bw3.pl added

perl script that demonstrates the problem

comment:1 by warmerdam, 17 years ago

Cc: warmerdam hobu added
Owner: changed from warmerdam to Ari Jolma

Ari,

Perhaps you could review this?

comment:2 by Ari Jolma, 17 years ago

Resolution: wontfix
Status: newclosed

This is a known issue, see for example this (in the dox files) http://map.hut.fi/doc/Geo-GDAL/html/create_raster.html

Instead of undef also $dataset->DESTROY could be called (see also http://www.swig.org/Doc1.3/Perl5.html#Perl5_nn41 )

This is a Swig issue. Swig creates for two variables for each objects and depending on the order (which is arbitrary) they are destroyed in the final cleanup (if undef is not used) the C API function deleting a Dataset is called or not.

It seems possible to fix this by changing the DESTROY method that is created by Swig:

sub DESTROY {
    my $self;
    if ($_[0]->isa('SCALAR')) {
	$self = $_[0];
    } else {
	return unless $_[0]->isa('HASH');
	$self = tied(%{$_[0]});
	return unless defined $self;
    }
    delete $ITERATORS{$self};
    if (exists $OWNER{$self}) {
	Geo::GDALc::delete_Dataset($self);
        delete $OWNER{$self};
    }
}

but this should be taken to the Swig developers. (I think I'll post this question in the Swig developers list)

Is there a similar problem in Python for example?

Ari

comment:3 by warmerdam, 17 years ago

Ari,

I'm not aware of a similar issue with Python. As soon as the python dataset variable falls out of scope the destroy/close stuff is normally called. Hobu?

comment:4 by Ari Jolma, 17 years ago

There is also no problem in Perl if the dataset variable is a local variable and it falls this way out of scope, i.e.:

{
    ...
    my $output_ds= $gtiff_driver->Create...
    ...
} # $output_ds falls out of scope here and is properly destroyed

the problem occurs only(?) if the dataset variable is destroyed in the final cleanup when Perl itself is closing

Note: See TracTickets for help on using tickets.