From: merch-redmine@... Date: 2019-07-07T16:31:55+00:00 Subject: [ruby-core:93592] [Ruby master Bug#10961] Zlib corrupts data when receive signal Issue #10961 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Closed It appears this was fixed between ruby 2.3 and 2.4: ``` $ ruby24 /home/jeremy/Downloads/zlib.rb 62780 generating len=1000000000 string... string length=1000000000 compressing... ^CINT decompressing... true $ ruby23 /home/jeremy/Downloads/zlib.rb 78994 generating len=1000000000 string... string length=1000000000 compressing... ^CINT /home/jeremy/Downloads/zlib.rb:13:in `deflate': data error (Zlib::DataError) from /home/jeremy/Downloads/zlib.rb:13:in `test_string' from /home/jeremy/Downloads/zlib.rb:25:in `block in
' from /home/jeremy/Downloads/zlib.rb:25:in `each' from /home/jeremy/Downloads/zlib.rb:25:in `
' ``` ---------------------------------------- Bug #10961: Zlib corrupts data when receive signal https://bugs.ruby-lang.org/issues/10961#change-79183 * Author: leiting (Lei Ting) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: 2.0.0-p353 2.2.0 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- 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: # ruby zlib.rb 37028 generating len=1000000000 string... string length=1000000000 compressing... ^CINT (press Ctrl+C or send a signal to the pid) zlib.rb:13:in `deflate': data error (Zlib::DataError) from zlib.rb:13:in `test_string' from zlib.rb:25:in `block in
' from zlib.rb:25:in `each' from zlib.rb:25:in `
' ---Files-------------------------------- zlib.rb (646 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: