Skip to content

fix: move #[global_allocator] from lib to binary crate - #85

Closed
JP-Ellis wants to merge 1 commit into
masterfrom
fix/move-global-allocate-to-bin-crate
Closed

fix: move #[global_allocator] from lib to binary crate#85
JP-Ellis wants to merge 1 commit into
masterfrom
fix/move-global-allocate-to-bin-crate

Conversation

@JP-Ellis

@JP-Ellis JP-Ellis commented Jun 2, 2026

Copy link
Copy Markdown
Member

When pact-stub-server is used as a library (e.g. embedded in pact-cli), the #[global_allocator] declaration in lib.rs imposed mimalloc as the allocator for the entire host binary. This caused mimalloc to abort() with no Rust panic message when OpenTelemetry was active in the host process, because OTEL's internal heap activity violated a mimalloc invariant.

Moving the declaration to bin/pact-stub-server.rs means:

  • The standalone pact-stub-server binary still uses mimalloc (no change in performance characteristics)
  • Library consumers get the system/default allocator and are not affected

When pact-stub-server is used as a library (e.g. embedded in pact-cli),
the #[global_allocator] declaration in lib.rs imposed mimalloc as the
allocator for the entire host binary. This caused mimalloc to abort() —
with no Rust panic message — when OpenTelemetry was active in the host
process, because OTEL's internal heap activity violated a mimalloc
invariant.

Moving the declaration to bin/pact-stub-server.rs means:
- The standalone pact-stub-server binary still uses mimalloc (no change
  in performance characteristics)
- Library consumers get the system/default allocator and are not affected

Assisted-by: Claude Code:claude-sonnet-4-6
@JP-Ellis JP-Ellis closed this Jun 2, 2026
@JP-Ellis
JP-Ellis deleted the fix/move-global-allocate-to-bin-crate branch June 2, 2026 05:28
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