-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Zlib::Reader: Reading to EOF deadlocks application #6575
Comments
when i use my static crystal analyze tool, i find one bug in zlib flate code, not sure it related here or not, or how to test it (just want to note it somewhere). ret = LibZ.inflateSetDictionary(pointerof(@stream), dict, dict.size)
next if ret == LibZ::Error::OK ret it Int, and compared with enum, this is always false. |
Interesting! Unfortunately I don't think that applies here, at least I'm pretty sure - I monkey patched |
wonder if related to #4650 ... |
Good call, maybe! 🙂 Reviewing the last few comments it seems like it may be, though the |
Zlib::Reader
can deadlock the application if you read to EOF:I've created https://github.com/z64/zlib-freeze which contains a sample data blob and the above code that demonstrates the deadlock, as well as an excerpt from
lldb
inREADME.md
.Background
I found this while implementing business logic of a websocket protocol that sends chunks of zlib-compressed data over multiple frames, where you buffer each frame received until a "end of flush" binary suffix is read; so you must use a single instance of
Zlib::Reader
throughout your connections lifetime over multiple frames. Trying to inflate a single blob (shown in the above repo) deadlocked the app.I suspect the correct behavior here should be to raise an exception; as a workaround I'm infalting into a slice (
reader.read(slice)
) which will not exhibit this deadlock behavior.The text was updated successfully, but these errors were encountered: