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

Adapt to changes in HDF5 v0.14 release #145

Merged
merged 13 commits into from
Nov 24, 2020
Merged

Conversation

jmert
Copy link
Contributor

@jmert jmert commented Sep 18, 2020

HDF5.jl v0.14.0 has made a number of significant changes to the interface — this PR updates MAT for those changes.

a_create -> create_attribute
d_create -> create_dataset
g_create -> create_group
p_create -> create_property
a_read -> read_attribute
a_write -> write_attribute
d_write -> write_attribute
attrs -> attributes
@codecov

This comment has been minimized.

@jmert jmert force-pushed the HDF5_v0.14 branch 2 times, most recently from 3dd6190 to 314a42b Compare November 12, 2020 19:39
@jmert jmert force-pushed the HDF5_v0.14 branch 3 times, most recently from 4ad6b66 to 9103be1 Compare November 24, 2020 18:07
@jmert jmert marked this pull request as ready for review November 24, 2020 18:13
@jmert jmert requested a review from musm November 24, 2020 18:13
@jmert jmert changed the title Adapt to changes in next HDF5 release Adapt to changes in HDF5 v0.14 release Nov 24, 2020
@musm musm merged commit e964bf0 into JuliaIO:master Nov 24, 2020
@jmert jmert deleted the HDF5_v0.14 branch November 24, 2020 18:15
@jmert
Copy link
Contributor Author

jmert commented Nov 24, 2020

Gah, I've seen the Linux x64/Julia 1.5.3 CI failure (https://github.com/JuliaIO/MAT.jl/runs/1449246460) a couple of times while rebasing this PR, but I cannot reproduce locally and it went away when I temporarily stuck @show HDF5.checkvalid(x) statements on parent, dtype, and stype here.

@musm
Copy link
Member

musm commented Nov 24, 2020

Hmm, interesting. Should I hold off on the registration you think?

@jmert
Copy link
Contributor Author

jmert commented Nov 24, 2020

I was hoping not, but it probably deserves a bit of investigation. I'll try running the tests a few more times repeatedly on my Linux machines to see if I can trigger, but I'm afraid it's going to be some subtle thing like somehow a finalizer is running early and could be hard to reliably reproduce. If you have a Linux machine of your own (especially if Ubuntu like CI; mine are Arch), maybe you could try running the tests a few times?

@musm
Copy link
Member

musm commented Nov 24, 2020

I won't cancel the registration PR since this looks intermittent and could be addressed in a patch release.

I'll try to see if I can trigger it, although it would be using Ubuntu through WSL2.

@jmert
Copy link
Contributor Author

jmert commented Nov 24, 2020

Forcefully running the GC allows me to reproduce the error:

diff --git a/src/MAT_HDF5.jl b/src/MAT_HDF5.jl
index 87be6be..e6cf144 100644
--- a/src/MAT_HDF5.jl
+++ b/src/MAT_HDF5.jl
@@ -356,6 +356,10 @@ function m_writearray(parent::HDF5Parent, name::String, adata::AbstractArray{Com
     try
         stype = dataspace(adata)
         if compress
+            GC.gc(true)
+            @show parent
+            @show dtype
+            @show stype
             obj_id = create_dataset(parent, name, dtype, stype;
                               compress = 3, chunk = HDF5.heuristic_chunk(adata))
         else

dtype is closed/invalid after the GC sweep.

jmert added a commit to jmert/HDF5.jl that referenced this pull request Nov 24, 2020
By defining `Base.convert(::Type{hid_t}, x)` for all of the high-level
object types, implicit conversion to an integer is permitted.
This has the unfortunate consquence --- as found in JuliaIO/MAT.jl#145
and JuliaIO/MAT.jl#151 --- that incorrectly "wrapping" a wrapped object
was allowed, but doing so allows the garbage collector to reap the
object too early.

The main reason for allowing conversion from an object to integer
(namely `HDF5.hid_t`) is to support passing the objects to `ccall`s
without requiring reaching into the `obj.id` raw integer ID.

We can easily still allow this while disabling implicit conversion by
just replacing all definitions of `Base.convert` with `Base.cconvert`.
Doing this would have caught the mistake in MAT.jl at the Julia type
level rather than having to debug a runtime error.
matrix:
version:
- '1.3'
- '1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this actually runs the latest release version (i.e 1.5) (unlike travis)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it now does. Maybe it was fixed, but I was sure it did not several months ago when transitioning HDF5.jl

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the CI logs, it looks like it does — it reports downloading Julia v1.5.3: https://github.com/JuliaIO/MAT.jl/pull/145/checks?check_run_id=1449246460#step:3:6

musm pushed a commit to JuliaIO/HDF5.jl that referenced this pull request Nov 25, 2020
…#750)

By defining `Base.convert(::Type{hid_t}, x)` for all of the high-level
object types, implicit conversion to an integer is permitted.
This has the unfortunate consquence --- as found in JuliaIO/MAT.jl#145
and JuliaIO/MAT.jl#151 --- that incorrectly "wrapping" a wrapped object
was allowed, but doing so allows the garbage collector to reap the
object too early.

The main reason for allowing conversion from an object to integer
(namely `HDF5.hid_t`) is to support passing the objects to `ccall`s
without requiring reaching into the `obj.id` raw integer ID.

We can easily still allow this while disabling implicit conversion by
just replacing all definitions of `Base.convert` with `Base.cconvert`.
Doing this would have caught the mistake in MAT.jl at the Julia type
level rather than having to debug a runtime error.
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

Successfully merging this pull request may close these issues.

2 participants