Zlib corrupts data when receive signal
When receiving signal on main thread, Zlib::Deflate.deflate will be interrupted in zstream_run_func (zlib.c), thus producing unfinished output buffer.
Zlib::Deflate.deflate will return normally, without error, but the return value will be corrupted buffer and can't be decompressed.
Preferred fix: zstream_run() should check if err is Z_STREAM_END, if not, raise an error instead of return normally.
run zlib.rb to reproduce this problem:
generating len=1000000000 string...
^CINT (press Ctrl+C or send a signal to the pid)
deflate': data error (Zlib::DataError) from zlib.rb:13:in test_string'
block in <main>' from zlib.rb:25:in each'
from zlib.rb:25:in `'