Skip to content

Respect repr(align) on functions #4282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
RalfJung opened this issue Apr 20, 2025 · 0 comments · Fixed by rust-lang/rust#140072
Closed

Respect repr(align) on functions #4282

RalfJung opened this issue Apr 20, 2025 · 0 comments · Fixed by rust-lang/rust#140072
Labels
A-interpreter Area: affects the core interpreter C-bug Category: This is a bug. I-wrong Impact: makes Miri produce incorrect program behavior

Comments

@RalfJung
Copy link
Member

There's a #[repr(align(N))] attribute on functions (rust-lang/rust#82232). Miri currently ignores this when assigning addresses to functions; we should fix that.

@RalfJung RalfJung added C-bug Category: This is a bug. A-interpreter Area: affects the core interpreter I-wrong Impact: makes Miri produce incorrect program behavior labels Apr 20, 2025
ChrisDenton added a commit to ChrisDenton/rust that referenced this issue Apr 22, 2025
handle function alignment in miri

tracking issue: rust-lang#82232
Fixes rust-lang/miri#4282

The `#[repr(align(N))]` attribute on functions was ignored when using miri. For such a function, its address should be a multiple of `N`.

There is some further discussion in the thread [#t-compiler/const-eval > function address alignment](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/function.20address.20alignment) on how `dyn Fn` should be handled. The behavior there appears to be consistent between miri and nightly, though both may be incorrect. In any case, that can be resolved separately.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 23, 2025
Rollup merge of rust-lang#140072 - folkertdev:miri-fn-align, r=RalfJung

handle function alignment in miri

tracking issue: rust-lang#82232
Fixes rust-lang/miri#4282

The `#[repr(align(N))]` attribute on functions was ignored when using miri. For such a function, its address should be a multiple of `N`.

There is some further discussion in the thread [#t-compiler/const-eval > function address alignment](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/function.20address.20alignment) on how `dyn Fn` should be handled. The behavior there appears to be consistent between miri and nightly, though both may be incorrect. In any case, that can be resolved separately.
github-actions bot pushed a commit that referenced this issue Apr 23, 2025
handle function alignment in miri

tracking issue: rust-lang/rust#82232
Fixes #4282

The `#[repr(align(N))]` attribute on functions was ignored when using miri. For such a function, its address should be a multiple of `N`.

There is some further discussion in the thread [#t-compiler/const-eval > function address alignment](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/function.20address.20alignment) on how `dyn Fn` should be handled. The behavior there appears to be consistent between miri and nightly, though both may be incorrect. In any case, that can be resolved separately.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-interpreter Area: affects the core interpreter C-bug Category: This is a bug. I-wrong Impact: makes Miri produce incorrect program behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant