Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't dump closed file handle #366

Closed
ggggggggg opened this issue Feb 6, 2017 · 10 comments
Closed

Can't dump closed file handle #366

ggggggggg opened this issue Feb 6, 2017 · 10 comments

Comments

@ggggggggg
Copy link
Contributor

It seems like this should work

julia> h5 = h5open(tempname(),"w")
HDF5 data file: /var/folders/_0/25kp6h7x25v6vyjv2yjlcnkm000wrm/T/juliaBebRVv

julia> close(h5)

julia> dump(h5)
HDF5-DIAG: Error detected in HDF5 (1.8.18) thread 0:
  #000: H5Gdeprec.c line 844 in H5Gget_num_objs(): not a location ID
    major: Invalid arguments to routine
    minor: Inappropriate type
  #001: H5Gloc.c line 253 in H5G_loc(): invalid object ID
    major: Invalid arguments to routine
    minor: Bad value
ERROR: Error getting group length
 in h5g_get_num_objs at /Users/user/.julia/v0.5/HDF5/src/HDF5.jl:2104 [inlined]
 in length(::HDF5.HDF5File) at /Users/user/.julia/v0.5/HDF5/src/HDF5.jl:959
 in dump(::IOContext{Base.TTY}, ::HDF5.HDF5File, ::Int64, ::String) at /Users/user/.julia/v0.5/HDF5/src/HDF5.jl:1081
 in #dump#323 at ./show.jl:1226 [inlined]
 in (::Base.#kw##dump)(::Array{Any,1}, ::Base.#dump, ::IOContext{Base.TTY}, ::HDF5.HDF5File) at ./<missing>:0
 in dump(::HDF5.HDF5File) at ./show.jl:1227
@musm
Copy link
Member

musm commented Feb 15, 2017

This work for me. Try checking out master and try again.

@ggggggggg
Copy link
Contributor Author

ggggggggg commented Mar 15, 2017

I still see the same behavior on Master. The following is after I ran Pkg.checkout("HDF5") in a previous julia terminal.

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.5.0 (2016-09-19 18:14 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-apple-darwin13.4.0

julia> using HDF5

julia> f = h5open(tempname(),"w")
HDF5 data file: /var/folders/_0/25kp6h7x25v6vyjv2yjlcnkm000wrm/T/julia2zNuhi

julia> close(f)

julia> dump(f)
HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 0:
  #000: H5Gdeprec.c line 796 in H5Gget_num_objs(): not a location ID
    major: Invalid arguments to routine
    minor: Inappropriate type
  #001: H5Gloc.c line 253 in H5G_loc(): invalid object ID
    major: Invalid arguments to routine
    minor: Bad value
HDF5.HDF5File len 0
ERROR: File or object has been closed
 in checkvalid at /Users/user/.julia/v0.5/HDF5/src/HDF5.jl:677 [inlined]
 in names(::HDF5.HDF5File) at /Users/user/.julia/v0.5/HDF5/src/HDF5.jl:997
 in dump(::IOContext{Base.TTY}, ::HDF5.HDF5File, ::Int64, ::String) at /Users/user/.julia/v0.5/HDF5/src/HDF5.jl:1082
 in #dump#323 at ./show.jl:1226 [inlined]
 in (::Base.#kw##dump)(::Array{Any,1}, ::Base.#dump, ::IOContext{Base.TTY}, ::HDF5.HDF5File) at ./<missing>:0
 in dump(::HDF5.HDF5File) at ./show.jl:1227

julia> Pkg.installed("HDF5")
v"0.7.3+"

@musm
Copy link
Member

musm commented Mar 15, 2017

I now get the same error

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.0-pre.alpha.140 (2017-03-14 00:06 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 58ed252* (1 day old master)
|__/                   |  x86_64-w64-mingw32

julia>  using HDF5

julia> f = h5open(tempname(),"w")
HDF5 data file: C:\Users\Mus\AppData\Local\Temp\jl_DFB0.tmp

julia> close(f)

julia> dump(f)
HDF5-DIAG: Error detected in HDF5 (1.8.13) thread 0:
  #000: /home/abuild/rpmbuild/BUILD/hdf5-1.8.13/src/H5Gdeprec.c line 844 in H5Gget_num_objs(): not a location ID
    major: Invalid arguments to routine
    minor: Inappropriate type
  #001: /home/abuild/rpmbuild/BUILD/hdf5-1.8.13/src/H5Gloc.c line 253 in H5G_loc(): invalid object ID
    major: Invalid arguments to routine
    minor: Bad value
ERROR: Error getting group length
Stacktrace:
 [1] h5g_get_num_objs at C:\Users\Mus\.julia\v0.6\HDF5\src\HDF5.jl:2135 [inlined]
 [2] length(::HDF5.HDF5File) at C:\Users\Mus\.julia\v0.6\HDF5\src\HDF5.jl:957
 [3] dump(::IOContext{Base.TTY}, ::HDF5.HDF5File, ::Int64, ::String) at C:\Users\Mus\.julia\v0.6\HDF5\src\HDF5.jl:1079
 [4] #dump#247 at .\show.jl:1294 [inlined]
 [5] (::Base.#kw##dump)(::Array{Any,1}, ::Base.#dump, ::IOContext{Base.TTY}, ::HDF5.HDF5File) at .\<missing>:0
 [6] dump(::HDF5.HDF5File) at .\show.jl:1295

@musm
Copy link
Member

musm commented Apr 29, 2017

what is the desired output in this case?
ERROR: File or object has been closed ? or something else
I mean is the problem that the error msg is not helpful?

what can always add a checkisvalid(x) to the dump function, not sure if this what is requrested/wanted

@ggggggggg
Copy link
Contributor Author

Thats a good question. I was using dump hoping to see the fields and their values, but that apparently isn't what it does. I guess the desired output would be something as close as possible to the output for an open hdf5 file. The output for an open hdf5 file is

julia> using HDF5

julia> h5 = h5open(tempname(),"w")
HDF5 data file: /var/folders/_0/25kp6h7x25v6vyjv2yjlcnkm000wrm/T/juliaCuPul3

julia> dump(h5)
HDF5.HDF5File len 0

For comparison, the output of an open and close file (via open) are quite similar:

julia> f = open(tempname(),"w")
IOStream(<file /var/folders/_0/25kp6h7x25v6vyjv2yjlcnkm000wrm/T/juliaJ3OaYS>)

julia> dump(f)
IOStream
  handle: Ptr{Void} Ptr{Void} @0x000000011f4db5c0
  ios: Array{UInt8}((152,)) UInt8[0x00,0xf0,0x5b,0x19,0x01,0x00,0x00,0x00,0x00,0x00  …  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
  name: String "<file /var/folders/_0/25kp6h7x25v6vyjv2yjlcnkm000wrm/T/juliaJ3OaYS>"
  mark: Int64 -1

julia> close(f)

julia> dump(f)
IOStream
  handle: Ptr{Void} Ptr{Void} @0x000000011f4db5c0
  ios: Array{UInt8}((152,)) UInt8[0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00  …  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00]
  name: String "<file /var/folders/_0/25kp6h7x25v6vyjv2yjlcnkm000wrm/T/juliaJ3OaYS>"
  mark: Int64 -1

@musm
Copy link
Member

musm commented Apr 30, 2017

Ok that makes sense. I agree, it would be nice if it paralleled open.

@yuyichao
Copy link
Contributor

Note that HDF5.jl shouldn't override dump. JuliaLang/julia#15707

@musm
Copy link
Member

musm commented Apr 30, 2017

thanks @yuyichao , ok so it seems we should remove dump in favor of printing the information instead in using show

@yuyichao
Copy link
Contributor

That sounds reasonable for me.
You can also define custom functions to print additional information though the verbose (compat) setting in IOContext might be enough. I think it's also reasonable to assume that printing an object shouldn't error. If the file is closed, the printing can just say that instead of throwing an error.

@musm
Copy link
Member

musm commented May 30, 2017

closed by #395

@musm musm closed this as completed May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants