Skip to content

fix(discord): pin flate2 to system zlib for gateway decompression - #1554

Closed
Reese-max wants to merge 2 commits into
openabdev:mainfrom
Reese-max:devin/issue-1535
Closed

Reese-max wants to merge 2 commits into
openabdev:mainfrom
Reese-max:devin/issue-1535

Conversation

@Reese-max

Copy link
Copy Markdown

Summary

  • serenity inflates every Discord gateway payload through flate2 with its default rust_backend (miniz_oxide + simd-adler32). That stack is implicated in the post-connect SIGSEGVs reported on x86_64 macOS release builds in SIGSEGV on x86_64 macOS after commit 843bb729 (observer/lobby Phase 1 scaffold) — Discord gateway crash loop #1531 (fault inside miniz_oxide::inflate in ShardRunner) and SIGSEGV in discord::Handler::handle_config_command after connect — 0.10.0-beta.4 release binary (macOS x86_64) #1535 (crash surfacing in handle_config_command during post-connect command sync).
  • The discord feature now enables openab-core's flate2 dep with the zlib feature. any_c_zlib outranks rust_backend in flate2's backend selection, so all flate2 users in the build move to the OS zlib — removing the pure-Rust decompressor from the gateway hot path.
  • Regression guard: tests/discord_gateway_zlib.rs asserts the manifest wiring and libz-sys lockfile resolution.
  • A mechanical cargo fmt --all normalization commit plus a workspace_fmt_hygiene guard test are included because the tree had drifted from cargo fmt --all -- --check under current stable rustfmt (same drift fixed on the issue-1538 branch).

Refs #1535

Review Contract

Goal

Stop the post-connect SIGSEGVs on x86_64 macOS builds by removing miniz_oxide/simd-adler32 from serenity's gateway decompression path, via a dependency-feature change with no runtime code changes.

Non-goals

Accepted Residual Risks

Acceptance Criteria

  • tests/discord_gateway_zlib.rs passes: discord feature includes dep:flate2 with zlib feature, and Cargo.lock resolves libz-sys.
  • cargo fmt --all -- --check, cargo test --workspace, and cargo clippy --workspace --all-targets -- -D warnings pass on the candidate and on a clean detached replay (all verified).
  • windows-gnu cross-check attempted: cannot run in this environment (pre-existing x86_64-w64-mingw32-gcc absence; ring build script fails identically at base). libz-sys supports mingw targets via bundled zlib.

Follow-ups

Generated with Devin

serenity inflates every gateway payload through flate2's default
`rust_backend` (miniz_oxide + simd-adler32). That stack is implicated in
post-connect SIGSEGVs on x86_64 macOS release builds (openabdev#1531 saw the fault
inside miniz_oxide::inflate in ShardRunner; openabdev#1535 saw it surface in
handle_config_command during post-connect command sync).

Force flate2's `zlib` feature whenever the `discord` feature is enabled.
`any_c_zlib` outranks `rust_backend` in flate2's backend selection, so all
flate2 users in the build (gateway decompress, png, zip/pre-seed) move to
the OS zlib. This removes the pure-Rust decompressor from the gateway hot
path at the cost of linking the platform libz, which is always present on
supported targets.

Refs openabdev#1535

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@openab-app openab-app Bot added the closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours. label Sep 30, 2026
@openab-app

openab-app Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Caution

This PR is missing a Discord Discussion URL in the body.
This PR will be automatically closed in 24 hours if the link is not added.

All PRs must reference a prior Discord discussion to ensure community alignment before implementation.

Please edit the PR description to include a link like:

Discord Discussion URL: https://discord.com/channels/...

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

🔒 Auto-closing: this PR has had the closing-soon label for more than 1 days without activity from the author.

If you'd like to continue working on this, please submit a new PR and link to this one if necessary.

@github-actions github-actions Bot closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

closing-soon PR missing Discord Discussion URL — will auto-close in 24 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant