Skip to content

Blosc silently fails with 2GB buffer #80

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

Closed
jeromekelleher opened this issue May 9, 2018 · 1 comment
Closed

Blosc silently fails with 2GB buffer #80

jeromekelleher opened this issue May 9, 2018 · 1 comment
Labels
Milestone

Comments

@jeromekelleher
Copy link
Member

>>> import numcodecs
>>> import numpy as np                                                                                   
>>> a = np.ones(1024**3, dtype=np.int8)
>>> a.nbytes
1073741824
>>> codec = numcodecs.Blosc()
>>> x = codec.encode(a)
>>> len(x)
4505616
>>> a = np.ones(2 * 1024**3, dtype=np.int8)
>>> x = codec.encode(a)                                                                                  
Input buffer size cannot exceed 2147483631 bytes
>>> codec.decode(x)
# Freezes interpreter

It looks like Blosc is raising this error and it's not being caught here because csize is declared as size_t, and so cannot be negative.

Any thoughts @alimanfoo? Should be an easy fix, but it's not entirely clear how to test this. Do you know of any other ways we can provoke errors in blosc which don't involve mallocing 2GB?

@alimanfoo
Copy link
Member

You could try corrupting a compressed buffer. I.e., create some compressed bytes via encode(), then remove some leading or trailing bytes then try to decode().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants