R HDF5 library errors

Dear Dr. Dietze,

Hugh Pumphrey wrote:

Many thanks for your bug report.

In order to make further progress on this, I suspect that we would need a test case

Barbara Jones at the HDF group pointed me at the discussion of your problem in the HDF Forum mailing list

http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

In this, you give the following test case (corrected for a typo and also to use a variable name that is not an R function).

···

-----------------------------

library(hdf5)
  mydata = 1:10
  hdf5save("test.h5","mydata")

   (exit from R and then re-start R)

library(hdf5)
hdf5load("test.h5")
mydata

              ---------------------------------

On my computer this works exactly as expected, printing
  [1] 1 2 3 4 5 6 7 8 9 10

Furthermore, running the h5dump utility on the file test.h5 returns the following:

hcp@holly:~/wrk/R$ h5dump test.h5
HDF5 "test.h5" {
GROUP "/" {
    DATASET "mydata" {
       DATATYPE H5T_STD_I32LE
       DATASPACE SIMPLE { ( 10 ) / ( 10 ) }
       DATA {
       (0): 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
       }
    }
}

This all looks normal to me, so I think that the problem that you are having may be due to some aspect of your local system. I'm afraid that I can't easily diagnose what is wrong from here.

(I am using R version 2.7.1, version 1.6.7 of the R HDF5 package and HDF5 version 1.6.6 --- these are all what you get with the current stable release of Debian Linux on i386 architecture.)

Sorry that I don't have an immediate fix, but hopefully this info will push you in the right direction.

All the best

Hugh Pumphrey

--

============S=u=p=p=o=r=t===D=e=b=i=a=n===http://www.debian.org =======
Dr. Hugh C. Pumphrey | Tel. 0131-650-6026,Fax:0131-662-0478
School of GeoSciences | Replace 0131 with +44-131 if outside UK
The University of Edinburgh | Email: H.C.Pumphrey@ed.ac.uk
EDINBURGH EH9 3JN, Scotland | web: www.geos.ed.ac.uk/contacts/homes/hcp
================S=u=p=p=o=r=t==F=r=e=e==S=o=f=t=w=a=r=e================

Dear Dr. Dietze,

Hugh Pumphrey wrote:

Many thanks for your bug report.

In order to make further progress on this, I suspect that we would need a
test case

Barbara Jones at the HDF group pointed me at the discussion of your problem
in the HDF Forum mailing list

http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org

In this, you give the following test case (corrected for a typo and also to
use a variable name that is not an R function).
-----------------------------

library(hdf5)
mydata = 1:10
hdf5save("test.h5","mydata")

(exit from R and then re-start R)

library(hdf5)
hdf5load("test.h5")
mydata

        \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-

On my computer this works exactly as expected, printing
[1] 1 2 3 4 5 6 7 8 9 10

Furthermore, running the h5dump utility on the file test.h5 returns the
following:

hcp@holly:~/wrk/R$ h5dump test.h5
HDF5 "test.h5" {
GROUP "/" {
DATASET "mydata" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 10 ) / ( 10 ) }
DATA {
(0): 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
}
}
}
}

This all looks normal to me, so I think that the problem that you are having
may be due to some aspect of your local system. I'm afraid that I can't
easily diagnose what is wrong from here.

I've been able to reproduce the bug in Ubuntu 9.10 and 10.4 and Mac OS X
10.5.8 using a locally compiled version the HDF5 package and R-2.10. A
colleague who uses Windows XP reports that hdf5save (from the CRAN
binary package) works for R-2.7 but that it fails on subsequent versions.

I installed R-2.7.2 and hdf5_1.6.9 from source in Ubuntu 10.4 (amd_64) and the
above example works. On the systems where the example fails, running
the "file"
command using R's "system()" function gives a quick indication of a bad file:

system("file *.hdf *.h5")

ex1.hdf: Hierarchical Data Format (version 5) data
test.h5: data

On the systems I have tested where the simple example fails the
example(hdf5load)
does work.

(I am using R version 2.7.1, version 1.6.7 of the R HDF5 package and HDF5
version 1.6.6 --- these are all what you get with the current stable release
of Debian Linux on i386 architecture.)

Sorry that I don't have an immediate fix, but hopefully this info will push
you in the right direction.

I added "trace(hdf5cleanup)" to the examples. Using R-2.7.2 I see that
hdf5cleanup is called for both the simple example and for example(hdf5load),
but using R-2.10 it is not called for the simple example. IThe difference
appears to be that the "official" example is run via a function -- if I enter
the same commands manually then the cleanup function is not called and
I get garbage:

library(hdf5)

Warning message:
package 'hdf5' was built under R version 2.9.0 and help may not work correctly

trace(hdf5cleanup)
(m <- cbind(A = 1, diag(4)))

     A
[1,] 1 1 0 0 0
[2,] 1 0 1 0 0
[3,] 1 0 0 1 0
[4,] 1 0 0 0 1

ll <- list(a=1:10, b=letters[1:8]);
l2 <- list(C="c", l=ll); PP <- pi
hdf5save("ex1.hdf", "m","PP","ll","l2")

Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Using default transfer plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Using default transfer plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Using default transfer plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying

system('file ex1.hdf')

ex1.hdf: data

If I put the commands in a function:

ex=function(){(m <- cbind(A = 1, diag(4)))

+ ll <- list(a=1:10, b=letters[1:8]);
+ l2 <- list(C="c", l=ll); PP <- pi
+ hdf5save("ex1.hdf", "m","PP","ll","l2")
+ }

ex()

Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Using default transfer plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Using default transfer plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Setting buffer size in plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
Using default transfer plist
in vector_io: permuting
About to write
About to write
in vector_io: tidying
trace: hdf5cleanup(67108865L) <<<<<<<<<<<<<<<<<<<<<<<<<<<

system('file ex1.hdf')

ex1.hdf: Hierarchical Data Format (version 5) data

This explains why few people have encountered the bug -- most of
our applications use hdf5save inside functions. The problem appears
to be a change in the behaviour of R since 2.7, so THG is off the hook
for this one.

···

On Wed, Mar 31, 2010 at 12:30 PM, Hugh Pumphrey <hcp@staffmail.ed.ac.uk> wrote:

All the best

Hugh Pumphrey

--
George N. White III <aa056@chebucto.ns.ca>
Head of St. Margarets Bay, Nova Scotia