From H.C.Pumphrey at ed.ac.uk  Tue Mar 15 17:55:23 2011
From: H.C.Pumphrey at ed.ac.uk (H C Pumphrey)
Date: Tue, 15 Mar 2011 16:55:23 +0000
Subject: [Rd] Fixing the HDF5 package: the on.exit mystery
In-Reply-To: <4D70C05C.4040905@ed.ac.uk>
References: <4D70C05C.4040905@ed.ac.uk>
Message-ID: <4D7F99FB.4010304@ed.ac.uk>

H C Pumphrey wrote:

> I'm trying to fix a subtle bug in the hdf5 package. This package 
> provides an interfaces to the HDF5 library and hence allows one to load 
> data into R from files in the HDF5 format. The bug appeared during a 
> period in which R changed but the package did not. [details snipped]

I considered Prof. Ripley's suggestion to use finalizers but I'm not a good 
enough C programmer and rapidly became bogged down. For the moment I have 
fixed the bug in a more crude and obvious manner, by putting the relevant 
clean-up code at the end of both hdf5save() and hdf5load() and removing all 
references to the on.exit mechanism. This now means that if things work 
properly you can open and close as many HDF5 files as you like. (I imagine 
that the downside is that your file may be left open if some sorts of errors 
occur.  But I think this was probably happening anyway, given the fact that 
the on.exit mechanism wasn't working. )

I have also altered the code behind hdf5load() so that it ignores soft links 
inside a HDF5 file that don't have a target. Ideally your file should not 
contain such things. But if it does, then it is better to skirt round them 
than to fail whenever you meet one.

I will try uploading the package to CRAN at some point, but I think I'll use 
it myself for a bit to see whether it has any other nasties. If anyone wants 
to try it in the meantime you can get it at http://xweb.geos.ed.ac.uk/~hcp 
(scroll down to the bottom). I'd be particularly interested to know if it can 
be built on Windows/MacOS and, if not, why not.

Hugh

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



[Rd] Fixing the HDF5 package: the on.exit mystery
H C Pumphrey