rust-lang / rust-lang/rust

The combination of alloc_error_handler and target_features_11 is unsound

Open
#134,234 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-target_feature_11 I-unsound T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

The following code compiles:

#![feature(target_feature_11, alloc_error_handler)]

#[target_feature(enable = "avx")]
#[alloc_error_handler]
fn f(_: std::alloc::Layout) -> ! {
    panic!()
}

However, this is unsound if the allocation error handler is invoked on a machine that does not support avx.

The alloc_error_handler feature is still unstable, tracking issue: https://github.com/rust-lang/rust/issues/51540

This issue emerged during the stabilization PR for target_features_11: https://github.com/rust-lang/rust/pull/134090

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 by reproducing the example with the target_features_11 and alloc_error_handler features, then read tracking issue 51540 and stabilization PR 134090. Determine how the two features should interact so an allocation error handler cannot be invoked with unsupported AVX, and verify the resulting behavior on such a target.

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.