-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
SROA changes cause memory corruption in HDF5.jl Blosc decompression #43402
Comments
Ping @aviatesk |
Doing |
The value of |
It seems like |
Why is the value of |
|
So what I find suspicous is:
The ccall is supposed to root it's arguments, but it is not. It is only rooting |
On 1.7 we indeed root all the relevant values. So I don't think it's the SROA change, it's probably just surfaced it. |
Okay probably due to inlining |
After inlining:
What it should have been:
Note the missing: |
@mkitti did you check if this fixes the problem in HDF5 you observed? |
|
SROA changes in #43239 causes memory corruption in HDF5.jl Blosc decompression. The issue was git bisected to 1a1f3d7 .
Background
HDF5.jl version 0.15.7 implements a Blosc compression plugin. The plugin is a Julia function
blosc_filter
which is passed to the HDF5 C library as a C function pointer via@cfunction
. This filter implements both compression and decompression. The issue occurs during decompression.https://github.com/JuliaIO/HDF5.jl/blob/af25a33934623e0e18ec25c2711e42be725ab5fe/src/blosc_filter.jl#L81-L85
During decompression,
blosc_filter
callsBlosc.cbuffer_sizes
which is reproduced below.The source code for
blosc_cbuffer_sizes
is located here:https://github.com/Blosc/c-blosc/blob/master/blosc/blosc.c#L2101-L2117
What appears to be happening after 1a1f3d7 is that the memory for
outbuf_size
is being corrupted.Blosc.blosc_decompress
detects the corruption and returns an error code. The issue can be mitigated by modifyingblosc_filter
in HDF5.jl to preserve the outputscbytes
andblocksize
until after the execution ofBlosc.blosc_decompress
. Perhaps this preserves theRef
s long enough so that the underlying memory they are associated with is not modified. This doesn't make any sense to me given Julia's semantics.This mitigation is deployed in pull request 880 to HDF5.jl which is expected to be merged as HDF5.jl 0.16.0.
JuliaIO/HDF5.jl@740983e#diff-8ec4f00da08b40e9b455e957caf58d485f8389d51504c1f4f9fcf1685c270b90R99
Minimum working example
HDF5 is at 0.15.7. Derived from https://github.com/JuliaIO/HDF5.jl/blob/v0.15.7/test/plain.jl
Execution under 1a1f3d7 (#43239)
Execution under c624d4f (previous commit, #43208)
No error. No output.
Environment
The text was updated successfully, but these errors were encountered: