Build warning: SBF stack frame exceeds 4096 byte limit by 8 bytes #69

Closed
opened 2026-03-24 04:32:39 +00:00 by Brouie · 3 comments
Brouie commented 2026-03-24 04:32:39 +00:00 (Migrated from gitlab.com)

During anchor build on feat/solana-integration (76c7cc6+), bridge program emits: Error: Function _ZN4core5slice4sort6stable14driftsort_main Stack offset of 4104 exceeded max offset of 4096 by 8 bytes. Estimated frame size: 4160 bytes. Program still compiles, deploys, and passes 119/119 tests on localnet. However the warning says exceeding max may cause undefined behavior during execution. Flagging for review — may need to reduce stack usage in the sort path or use heap allocation.

During anchor build on feat/solana-integration (76c7cc6+), bridge program emits: Error: Function _ZN4core5slice4sort6stable14driftsort_main Stack offset of 4104 exceeded max offset of 4096 by 8 bytes. Estimated frame size: 4160 bytes. Program still compiles, deploys, and passes 119/119 tests on localnet. However the warning says exceeding max may cause undefined behavior during execution. Flagging for review — may need to reduce stack usage in the sort path or use heap allocation.
PlasticDigits commented 2026-03-24 06:29:37 +00:00 (Migrated from gitlab.com)

mentioned in commit dd7f86198b

mentioned in commit dd7f86198b37d94ac6ed4029381bfe330af79933
PlasticDigits commented 2026-03-24 06:29:42 +00:00 (Migrated from gitlab.com)

@brouie could you review when you have a moment?

Change: vendored solana-slot-hashes 2.2.1 under packages/contracts-solana/patches/solana-slot-hashes and wired it with [patch.crates-io] in packages/contracts-solana/Cargo.toml. SlotHashes::new now uses sort_unstable_by instead of sort_by so the SBF link step no longer pulls in core stable sort (driftsort_main), which was tripping the 4096-byte stack frame warning.

Verify: anchor build in packages/contracts-solana completes without the driftsort stack error.

Pushed: feat/solana-integration @ dd7f861 (remove the patch when upstream fixes or the toolchain changes).

@brouie could you review when you have a moment? **Change:** vendored `solana-slot-hashes` 2.2.1 under `packages/contracts-solana/patches/solana-slot-hashes` and wired it with `[patch.crates-io]` in `packages/contracts-solana/Cargo.toml`. `SlotHashes::new` now uses `sort_unstable_by` instead of `sort_by` so the SBF link step no longer pulls in `core` stable sort (`driftsort_main`), which was tripping the 4096-byte stack frame warning. **Verify:** `anchor build` in `packages/contracts-solana` completes without the driftsort stack error. **Pushed:** `feat/solana-integration` @ dd7f861 (remove the patch when upstream fixes or the toolchain changes).
Brouie commented 2026-03-24 06:54:28 +00:00 (Migrated from gitlab.com)

Verified — anchor build no longer shows stack overflow warning after patches/solana-slot-hashes. Build clean on both release and test profiles.

Verified — anchor build no longer shows stack overflow warning after patches/solana-slot-hashes. Build clean on both release and test profiles.
Brouie (Migrated from gitlab.com) closed this issue 2026-03-24 06:54:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-bridge-monorepo#69
No description provided.