Skip to content

Conversation

Jules-Bertholet
Copy link
Contributor

@Jules-Bertholet Jules-Bertholet commented Sep 6, 2025

Tracking issue: #146177

thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

@rustbot label A-attributes A-macros A-thread-locals F-static_align T-libs

@rustbot
Copy link
Collaborator

rustbot commented Sep 6, 2025

r? @lcnr

rustbot has assigned @lcnr.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 6, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 6, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

The Miri subtree was changed

cc @rust-lang/miri

@rustbot rustbot added A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-thread-locals Area: Thread local storage (TLS) F-static_align #![feature(static_align)] S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Sep 6, 2025
@rustbot rustbot assigned jhpratt and unassigned lcnr Sep 6, 2025
@Jules-Bertholet Jules-Bertholet force-pushed the static-align-thread-local branch from 67db3cb to dd3475c Compare September 6, 2025 17:14
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. and removed A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. labels Sep 6, 2025
@jdonszelmann jdonszelmann self-assigned this Sep 6, 2025
@jhpratt

This comment was marked as resolved.

@rustbot

This comment was marked as resolved.

@jhpratt jhpratt removed their assignment Sep 7, 2025
@jdonszelmann
Copy link
Contributor

@Jules-Bertholet would you mind rebasing? #146178 merged
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Sep 10, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 10, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@Jules-Bertholet Jules-Bertholet force-pushed the static-align-thread-local branch from dd3475c to 9cdfc77 Compare September 10, 2025 19:03
@rustbot

This comment has been minimized.

@Jules-Bertholet Jules-Bertholet force-pushed the static-align-thread-local branch from ca8d8b3 to ff97f2a Compare September 24, 2025 21:45
@Jules-Bertholet Jules-Bertholet force-pushed the static-align-thread-local branch from ff97f2a to a4e87e9 Compare September 26, 2025 17:51
@rust-log-analyzer

This comment has been minimized.

}
unsafe {
ptr.write(Value { value: i.and_then(Option::take).unwrap_or_else(f), key });
}
Copy link
Member

Choose a reason for hiding this comment

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

I think ptr is going to be leaked here if get/set panic -- can that happen? It looks like those have a quite a bit of code that they're running...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, should be better now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, actually, if get/set specifically panic there will be a leak. I’m not sure if that’s possible, but in any case any issue here is preexisting and not made worse by this PR. f can definitely panic though, as can drop_in_place; my latest commit accounts for that.

@Jules-Bertholet Jules-Bertholet force-pushed the static-align-thread-local branch from d12cb9b to cafb91d Compare October 1, 2025 16:25
@Jules-Bertholet Jules-Bertholet force-pushed the static-align-thread-local branch from cafb91d to 94f00f4 Compare October 1, 2025 16:28
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 1, 2025

📌 Commit 94f00f4 has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 1, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Oct 2, 2025
…d-local, r=Mark-Simulacrum

Support `#[rustc_align_static]` inside `thread_local!`

Tracking issue: rust-lang#146177

```rust
thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}
```

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

`@rustbot` label A-attributes A-macros A-thread-locals F-static_align T-libs
bors added a commit that referenced this pull request Oct 2, 2025
Rollup of 10 pull requests

Successful merges:

 - #146281 (Support `#[rustc_align_static]` inside `thread_local!`)
 - #146535 (mbe: Implement `unsafe` attribute rules)
 - #146585 (indexing: reword help)
 - #147004 (Tweak handling of "struct like start" where a struct isn't supported)
 - #147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
 - #147225 (Don't enable shared memory by default with Wasm atomics)
 - #147227 (implement `Box::take`)
 - #147231 (Extending `#[rustc_force_inline]` to be applicable to inherent methods)
 - #147233 (Initialize llvm submodule if not already the case to run citool)
 - #147236 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Oct 2, 2025
…d-local, r=Mark-Simulacrum

Support `#[rustc_align_static]` inside `thread_local!`

Tracking issue: rust-lang#146177

```rust
thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}
```

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

``@rustbot`` label A-attributes A-macros A-thread-locals F-static_align T-libs
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 2, 2025
…d-local, r=Mark-Simulacrum

Support `#[rustc_align_static]` inside `thread_local!`

Tracking issue: rust-lang#146177

```rust
thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}
```

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

`@rustbot` label A-attributes A-macros A-thread-locals F-static_align T-libs
bors added a commit that referenced this pull request Oct 2, 2025
Rollup of 9 pull requests

Successful merges:

 - #146281 (Support `#[rustc_align_static]` inside `thread_local!`)
 - #146535 (mbe: Implement `unsafe` attribute rules)
 - #146585 (indexing: reword help)
 - #147004 (Tweak handling of "struct like start" where a struct isn't supported)
 - #147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
 - #147225 (Don't enable shared memory by default with Wasm atomics)
 - #147227 (implement `Box::take`)
 - #147233 (Initialize llvm submodule if not already the case to run citool)
 - #147236 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 92aac1b into rust-lang:master Oct 2, 2025
10 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 2, 2025
rust-timer added a commit that referenced this pull request Oct 2, 2025
Rollup merge of #146281 - Jules-Bertholet:static-align-thread-local, r=Mark-Simulacrum

Support `#[rustc_align_static]` inside `thread_local!`

Tracking issue: #146177

```rust
thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}
```

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

``@rustbot`` label A-attributes A-macros A-thread-locals F-static_align T-libs
@Jules-Bertholet Jules-Bertholet deleted the static-align-thread-local branch October 2, 2025 14:45
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Oct 3, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#146281 (Support `#[rustc_align_static]` inside `thread_local!`)
 - rust-lang/rust#146535 (mbe: Implement `unsafe` attribute rules)
 - rust-lang/rust#146585 (indexing: reword help)
 - rust-lang/rust#147004 (Tweak handling of "struct like start" where a struct isn't supported)
 - rust-lang/rust#147221 (Forbid `//@ compile-flags: -Cincremental=` in tests)
 - rust-lang/rust#147225 (Don't enable shared memory by default with Wasm atomics)
 - rust-lang/rust#147227 (implement `Box::take`)
 - rust-lang/rust#147233 (Initialize llvm submodule if not already the case to run citool)
 - rust-lang/rust#147236 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-thread-locals Area: Thread local storage (TLS) F-static_align #![feature(static_align)] S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants