rust-lang / rust-lang/rust

`thread_local!` initialization code panics on some `aarch64-apple-darwin` envs, works on others

Open
#132,704 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-thread-locals C-bug E-needs-investigation O-AArch64 O-macos T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

https://github.com/near/near-sdk-rs/blob/master/near-sdk/src/environment/mock/mod.rs#L11-L16

thread_local! {
    static BLOCKCHAIN_INTERFACE: RefCell<MockedBlockchain>
         = RefCell::new(MockedBlockchain::default());
}

I expected to see this happen:

thread_local! initialization code for RefCell::new(MockedBlockchain::new)
works

Instead, this happened:

on unclarified aarch64-apple-darwin environment(s) thread_local!
panics on https://doc.rust-lang.org/src/core/ptr/mod.rs.html#1277 .

The issue doesn't reproduce on other aarch64-apple-darwin real macs,
and on macos-14-arm64 github actions vm.

Original issue: https://github.com/near/near-sdk-rs/issues/1252

Meta

rustc --version --verbose:

stable: 1.80, 1.81, 1.82 panics
beta 1.83 panics
nightly 1.84 panics

backtrace from original issue:
https://github.com/near/near-sdk-rs/issues/1252#issuecomment-2454692564

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the near-sdk-rs environment/mock/mod.rs snippet and reproduce the panic on an affected aarch64-apple-darwin environment, comparing it with a working real Mac or macos-14-arm64 GitHub Actions VM. Inspect the backtrace and the referenced core/ptr implementation, then use the original issue and its linked comment for context. Done means the platform-specific initialization failure is explained and a regression is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.