Skip to content

Keep ZSTREAM_IN_PROGRESS when raising InProgressError - #156

Open
mame wants to merge 1 commit into
ruby:masterfrom
mame:zlib-in-progress-flag
Open

mame wants to merge 1 commit into
ruby:masterfrom
mame:zlib-in-progress-flag

Conversation

@mame

@mame mame commented Oct 24, 2026

Copy link
Copy Markdown
Member

The ensure that clears the flag also ran for a call rejected by InProgressError. After rescuing it, the stream was no longer marked as in progress, so the recursive call prevented by [Bug #18358] was allowed again.

  s = Zlib.deflate(Random.bytes(1024**2))
  zi = Zlib::Inflate.new
  GC.stress = true
  zi.inflate(s) do
    zi << s rescue nil
    zi << s
  end
  #=> heap-use-after-free (with ASAN)

The ensure that clears the flag also ran for a call rejected by
InProgressError.  After rescuing it, the stream was no longer marked
as in progress, so the recursive call prevented by [Bug #18358] was
allowed again.

  s = Zlib.deflate(Random.bytes(1024**2))
  zi = Zlib::Inflate.new
  GC.stress = true
  zi.inflate(s) do
    zi << s rescue nil
    zi << s
  end
  #=> heap-use-after-free (with ASAN)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mame
mame force-pushed the zlib-in-progress-flag branch from a776b5e to 372abbd Compare October 24, 2026 20:17

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant