Skip to content

Disable brotli's default ffi-api feature in the Rust SDK - #6444

Open
Tyagiquamar wants to merge 1 commit into
clockworklabs:masterfrom
Tyagiquamar:fix/6430-brotli-ffi-symbols
Open

Tyagiquamar wants to merge 1 commit into
clockworklabs:masterfrom
Tyagiquamar:fix/6430-brotli-ffi-symbols

Conversation

@Tyagiquamar

Copy link
Copy Markdown
Contributor

Summary

spacetimedb-sdk depends on brotli = "3.5" with its default features. Those defaults are std and ffi-api, and ffi-api makes brotli export its C API (BrotliDecoder* and friends) from any cdylib that links the SDK. A host process that also loads a libcrypto built with Brotli support then binds those imports to the extension, keeps it mapped after unload, and breaks hot reloading (the reported symptom is godot-rust's hot reloading should only be set once panic).

Fixes #6430.

Root cause

  • Workspace Cargo.toml: brotli = "3.5" pulls in ffi-api transitively through default features.
  • The SDK only uses the Rust API (brotli::BrotliDecompress in sdks/rust/src/compression.rs), so the C surface is dead weight that leaks into every cdylib consumer.

Changes

  • Cargo.toml: brotli = { version = "3.5", default-features = false, features = ["std"] }, with a comment explaining why the defaults must stay off.
  • sdks/rust/Cargo.toml: inherit brotli from the workspace (it already did) and add toml as a dev-dependency for the new policy test.
  • sdks/rust/tests/brotli_ffi_api.rs: new test that parses the workspace and SDK manifests and fails if the SDK stops inheriting brotli, if default-features is re-enabled, or if ffi-api is listed.

Test plan

Feature resolution before and after (cargo tree -e features -p spacetimedb-sdk --invert brotli):

  • master: brotli feature "ffi-api" is present.
  • This branch: no ffi-api in the tree.

cargo fmt --check -p spacetimedb-sdk passes, and rustfmt --edition 2021 --check sdks/rust/tests/brotli_ffi_api.rs passes.

Local cargo test for the new target could not complete on this machine: there is no MSVC toolchain on Windows, and the Linux container build was killed by the Docker VM memory limit while compiling jemalloc/wasmtime. The dependency graph and formatting checks above ran locally; compilation and execution of brotli_ffi_api are left to CI.

@bfops

bfops commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Thank you for opening this fix! Our repo requires verified commit signatures - are you able to set that up and re-push the commit on this branch?

@bfops

bfops commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

also it looks like you(r agent) had some trouble completing testing:

Local cargo test for the new target could not complete on this machine: there is no MSVC toolchain on Windows, and the Linux container build was killed by the Docker VM memory limit while compiling jemalloc/wasmtime. The dependency graph and formatting checks above ran locally; compilation and execution of brotli_ffi_api are left to CI.

`brotli`'s default features include `ffi-api`, which exports the `Brotli*` C
API from any `cdylib` that links `spacetimedb-sdk`. A host that also loads a
libcrypto built with Brotli support binds those imports to the extension, so
the extension stays mapped after unload and hot reloading breaks.

Only the Rust API is used: `BrotliDecompress` in the SDK and `BrotliCompress`
in `spacetimedb-core`, both of which need just the `std` feature. Keep the
dependency at the workspace level so feature unification cannot re-enable
`ffi-api` through another member.

Adds `sdks/rust/tests/brotli_ffi_api.rs`, which fails if the defaults or the
`ffi-api` feature come back.
@Tyagiquamar
Tyagiquamar force-pushed the fix/6430-brotli-ffi-symbols branch from 18f3d54 to 689adb7 Compare November 7, 2026 16:15
@Tyagiquamar

Copy link
Copy Markdown
Contributor Author

Hi @bfops, re-signed the commit with verified GPG signature and pushed to the branch.

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.

Rust SDK: default brotli features export C symbols from cdylib clients

2 participants