Skip to content

Fix crash on macOS 26 due to objc2 signed/unsigned encoding mismatch#71

Merged
florianl merged 1 commit intoelastic:mainfrom
dalehamel:fix-macos-panic
Feb 12, 2026
Merged

Fix crash on macOS 26 due to objc2 signed/unsigned encoding mismatch#71
florianl merged 1 commit intoelastic:mainfrom
dalehamel:fix-macos-panic

Conversation

@dalehamel
Copy link
Contributor

On macOS 26 (Tahoe), the app panics at startup (when just called via cargo run on main) when winit (via eframe) enumerates NSScreen objects:


thread 'main' panicked at /Users/dalehamel/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/objc2-foundation-0.2.2/src/generated/NSEnumerator.rs:7:1:
invalid message send to -[_TtGCs23_ContiguousArrayStorageCSo8NSScreen_$ countByEnumeratingWithState:objects:count:]: expected return to have type code 'q', but found 'Q'
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

thread 'main' panicked at library/core/src/panicking.rs:225:5:
panic in a function that cannot unwind
stack backtrace:
   0:        0x10587e80c - std::backtrace_rs::backtrace::libunwind::trace::h674dcd02776dcc9c
                               at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:117:9
   1:        0x10587e80c - std::backtrace_rs::backtrace::trace_unsynchronized::haccaae8fb80e4531
                               at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:14
   2:        0x10587e80c - std::sys::backtrace::_print_fmt::h3191fc6495b0a516
                               at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:66:9
   3:        0x10587e80c - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h373e57e2286956dc
                               at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/std/src/sys/backtrace.rs:39:26
   4:        0x10589c638 - core::fmt::rt::Argument::fmt::hcee930b009d69e38
                               at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/fmt/rt.rs:173:76
   5:        0x10589c638 - core::fmt::write::h2c4a0b98b09e3b30
                               at /rustc/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/core/src/fmt/mod.rs:1465:25

The issue seems to be in a dependency 1:

The objc2 crate's encoding verifier expects a signed type code ('q') for countByEnumeratingWithState:objects:count: but the runtime returns unsigned ('Q'), causing a panic.

This is a known issue in objc2-foundation 0.2.2:

The fix was released as a feature flag relax-sign-encoding in objc2 0.5.2 (already a transitive dependency via eframe -> winit). Adding objc2 as a direct macOS-only dependency with this feature enabled activates it globally without requiring an eframe version bump.

Note: eframe has not yet upgraded to objc2 0.6.x which includes this fix by default (even latest eframe 0.33.x still uses objc2 0.5.x).

Footnotes

  1. FYI I didn't figure this one out myself, I had claude 4.6 do it so there might be a better way, I just needed to unblock myself and get devfiler working again, and thought i'd submit the fix back.

@dalehamel dalehamel requested a review from a team as a code owner February 10, 2026 19:48
@cla-checker-service
Copy link

cla-checker-service bot commented Feb 10, 2026

💚 CLA has been signed

On macOS 26 (Tahoe), the app panics at startup when winit (via eframe)
enumerates NSScreen objects. The objc2 crate's encoding verifier expects
a signed type code ('q') for countByEnumeratingWithState:objects:count:
but the runtime returns unsigned ('Q'), causing a panic.

This is a known issue in objc2-foundation 0.2.2:
- madsmtm/objc2#765
- madsmtm/objc2#566
- Fix: madsmtm/objc2#567

The fix was released as a feature flag `relax-sign-encoding` in objc2
0.5.2 (already a transitive dependency via eframe -> winit). Adding
objc2 as a direct macOS-only dependency with this feature enabled
activates it globally without requiring an eframe version bump.

Note: eframe has not yet upgraded to objc2 0.6.x which includes this
fix by default (even latest eframe 0.33.x still uses objc2 0.5.x).
Copy link
Member

@florianl florianl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix 🙏

@florianl florianl merged commit 3f0d4e5 into elastic:main Feb 12, 2026
4 checks passed
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.

2 participants