You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The SChunk passed to Python codec/filter callbacks dangles once the array is freed #793
Python codec and filter callbacks registered with blosc2.register_codec() / blosc2.register_filter() get an SChunk as their last argument (general_encoder, general_decoder, general_forward, general_backward in blosc2_ext.pyx). That object is a view over the C super-chunk with nothing that keeps the super-chunk alive. A callback that keeps it (e.g. to cache something per array) reads freed memory after the array is gone: wrong values, and under AddressSanitizer a heap-use-after-free in SChunk.nchunks.
The object is presumably only meant to be used during the call. If so, one option is to invalidate it when the callback returns (clear its pointer so that later use raises instead of reading freed memory), or at least to document that it must not be kept. Each callback also constructs a full blosc2.SChunk through its Python __init__ per call, which a lighter wrapper could avoid.
I used Claude Code (Anthropic) to find and reproduce this and draft the issue; I checked the repro.
Activity