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

Fix zlib missing handling of buffer error #6610

Merged
merged 5 commits into from
Aug 26, 2018

Conversation

asterite
Copy link
Member

Fixes #6575

The first commit fixes #6575: translating the code that reproduces the bug to ruby raises "buffer error", and we were missing handling that error. I additionally added a check for other potential errors too.

The next commits refactor and improve zilb, fixing a few bugs too, where a function would return Int and it was expected to return an Error (an enum). This was easily detected by using the question methods of enums instead of comparing them with enum values.

Finally, peeking some Ruby code that deals with zlib, I found out about the zError function to get a nice error message in case zlib's stream doesn't provide one.

It might be nice to include this fix in 0.26.1 /cc @bcardiff

@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib labels Aug 26, 2018
@asterite
Copy link
Member Author

Probably fixes #4650 too...

@@ -65,5 +65,15 @@ module Zlib
slice = Bytes.empty
reader.read(slice).should eq(0)
end

it "should raise bufer error on error (#6575)" do
Copy link
Member

Choose a reason for hiding this comment

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

buffer

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 5c314e0

@bcardiff
Copy link
Member

@asterite do you want do a rebase and squash that last commit or you prefer me to squash all together?

@asterite asterite force-pushed the bug/6575-zlib-buf-error branch from 5c314e0 to a1d775f Compare August 26, 2018 21:20
@asterite
Copy link
Member Author

@bcardiff Rebased against master! All the commits are self-contained and independent, but you can squash them all if you want.

@bcardiff
Copy link
Member

I ment that the last commit (typo) could be squashed into one of the previous ones.
It's fine, I will merge directly this.

@bcardiff bcardiff merged commit 65b8084 into crystal-lang:master Aug 26, 2018
@bcardiff bcardiff added this to the 0.26.1 milestone Aug 26, 2018
@Sija Sija mentioned this pull request Aug 26, 2018
@rdp
Copy link
Contributor

rdp commented Aug 29, 2018

I like this fix, it at allows fibers to at least not hang now, sweet! I had some question marks about if it should retry on Z_BUF_ERROR if there's more input to be had but it can be addressed later, if it's even a problem, thanks! ref: http://zlib.net/zlib_how.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zlib::Reader: Reading to EOF deadlocks application
5 participants