Skip to content

Thread#wakeup leads to Zlib::BufError #57

Open
@rabotyaga

Description

@rabotyaga

Minimal reproducible script:

require "securerandom"
require "stringio"
require "zlib"

content = SecureRandom.base64(5000)
gzipped = Zlib.gzip(content)

thr = Thread.new do
  loop do
    Zlib::GzipReader.new(StringIO.new(gzipped)).read
  end
end

loop do
  thr.wakeup
end

leads to

#<Thread:0x000000010511d090 gunzip.rb:8 run> terminated with exception (report_on_exception is true):
gunzip.rb:10:in `initialize': buffer error (Zlib::BufError)
	from gunzip.rb:10:in `new'
	from gunzip.rb:10:in `block (2 levels) in <main>'
	from gunzip.rb:9:in `loop'
	from gunzip.rb:9:in `block in <main>'
gunzip.rb:15:in `wakeup': killed thread (ThreadError)
	from gunzip.rb:15:in `block in <main>'
	from gunzip.rb:14:in `loop'
	from gunzip.rb:14:in `<main>'

The error doesn't happen, however, if we change Zlib::GzipReader.new(StringIO.new(gzipped)).read to Zlib.gunzip(gzipped), but still happens with Zlib.gzip(content).

Probably related to #49

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions