Skip to content

Lint against invalid POSIX symbol definitions#158522

Open
Urgau wants to merge 2 commits into
rust-lang:mainfrom
Urgau:runtime-symbols-posix
Open

Lint against invalid POSIX symbol definitions#158522
Urgau wants to merge 2 commits into
rust-lang:mainfrom
Urgau:runtime-symbols-posix

Conversation

@Urgau

@Urgau Urgau commented Jun 28, 2026

Copy link
Copy Markdown
Member

This PR extends the invalid_runtime_symbol_definitions and suspicious_runtime_symbol_definitions lints to lint againts the following POSIX symbols:

  • I/O: open, read, write, close
  • Alloc: malloc, realloc, free
  • Program: exit

This is meant to address the multiple reports of users tripping over std symbols:

Those symbols are defined in std, so as long as the std crate is imported (and we are on a UNIX-like target) we lint on those symbols.

Follow up to #155521

@rustbot rustbot added 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 Jun 28, 2026
@rustbot

rustbot commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

r? @chenyukang

rustbot has assigned @chenyukang.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

@Urgau Urgau changed the title Lint lint against invalid POSIX symbol definitions Lint against invalid POSIX symbol definitions Jun 28, 2026
@Urgau Urgau added the I-lang-nominated Nominated for discussion during a lang team meeting. label Jun 28, 2026
@Urgau Urgau force-pushed the runtime-symbols-posix branch from 315bb46 to 070c3d9 Compare June 28, 2026 12:41
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
tests/fail/tree_borrows/wildcard/strongly_protected_wildcard.rs ... ok
tests/fail/tree_borrows/wildcard/subtree_internal_relatedness_wildcard.rs ... ok

FAILED TEST: tests/fail/function_calls/check_arg_abi.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/function_calls" "tests/fail/function_calls/check_arg_abi.rs" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/function_calls/check_arg_abi.stderr` to the actual output
--- tests/fail/function_calls/check_arg_abi.stderr
+++ <stderr output>
---
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
+   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
+           found    `unsafe fn(usize) -> *mut std::ffi::c_void`
+   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
+   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
 error: aborting due to 1 previous error
 
---
   |
LL |         fn malloc(size: usize) -> *mut std::ffi::c_void;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `unsafe fn(usize) -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default

error: aborting due to 1 previous error



error: `calling a function with calling convention "C" using caller calling convention "Rust"` not found in diagnostics on line 7
##[error] --> tests/fail/function_calls/check_arg_abi.rs:7:39
  |
7 |         let _ = malloc(0); //~ ERROR: calling a function with calling convention "C" using caller calling convention "Rust"
  |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
  |

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/function_calls/check_arg_abi.rs:3:9
  |
3 |         fn malloc(size: usize) -> *mut std::ffi::c_void;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[invalid_runtime_symbol_definitions]: invalid definition of the runtime `malloc` symbol used by the standard library
  |

full stderr:
error: invalid definition of the runtime `malloc` symbol used by the standard library
##[error]  --> tests/fail/function_calls/check_arg_abi.rs:3:9
   |
LL |         fn malloc(size: usize) -> *mut std::ffi::c_void;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `unsafe fn(usize) -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default

error: aborting due to 1 previous error


full stdout:



FAILED TEST: tests/fail/function_calls/check_arg_count_too_few_args.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/function_calls" "tests/fail/function_calls/check_arg_count_too_few_args.rs" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/function_calls/check_arg_count_too_few_args.stderr` to the actual output
--- tests/fail/function_calls/check_arg_count_too_few_args.stderr
+++ <stderr output>
---
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
+   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
+           found    `unsafe extern "C" fn() -> *mut std::ffi::c_void`
+   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
+   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
 error: aborting due to 1 previous error
 
---
   |
LL |         fn malloc() -> *mut std::ffi::c_void;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `unsafe extern "C" fn() -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default

error: aborting due to 1 previous error



error: `Undefined Behavior: incorrect number of arguments for `malloc`: got 0, expected 1` not found in diagnostics on line 7
##[error] --> tests/fail/function_calls/check_arg_count_too_few_args.rs:7:38
  |
7 |         let _ = malloc(); //~ ERROR: Undefined Behavior: incorrect number of arguments for `malloc`: got 0, expected 1
  |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
  |

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/function_calls/check_arg_count_too_few_args.rs:3:9
  |
3 |         fn malloc() -> *mut std::ffi::c_void;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[invalid_runtime_symbol_definitions]: invalid definition of the runtime `malloc` symbol used by the standard library
  |

full stderr:
error: invalid definition of the runtime `malloc` symbol used by the standard library
##[error]  --> tests/fail/function_calls/check_arg_count_too_few_args.rs:3:9
   |
LL |         fn malloc() -> *mut std::ffi::c_void;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `unsafe extern "C" fn() -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default

error: aborting due to 1 previous error


full stdout:



FAILED TEST: tests/fail/function_calls/check_arg_count_too_many_args.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/function_calls" "tests/fail/function_calls/check_arg_count_too_many_args.rs" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/function_calls/check_arg_count_too_many_args.stderr` to the actual output
--- tests/fail/function_calls/check_arg_count_too_many_args.stderr
+++ <stderr output>
-error: Undefined Behavior: incorrect number of arguments for `malloc`: got 2, expected 1
+error: invalid definition of the runtime `malloc` symbol used by the standard library
   --> tests/fail/function_calls/check_arg_count_too_many_args.rs:LL:CC
    |
-LL |         let _ = malloc(1, 2);
+LL |         fn malloc(_: i32, _: i32) -> *mut std::ffi::c_void;
-   |                 ^^^^^^^^^^^^ Undefined Behavior occurred here
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
+   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
+           found    `unsafe extern "C" fn(i32, i32) -> *mut std::ffi::c_void`
+   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
+   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
-
 error: aborting due to 1 previous error
 

Full unnormalized output:
error: invalid definition of the runtime `malloc` symbol used by the standard library
##[error]  --> tests/fail/function_calls/check_arg_count_too_many_args.rs:3:9
   |
LL |         fn malloc(_: i32, _: i32) -> *mut std::ffi::c_void;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `unsafe extern "C" fn(i32, i32) -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default

error: aborting due to 1 previous error



error: `Undefined Behavior: incorrect number of arguments for `malloc`: got 2, expected 1` not found in diagnostics on line 7
##[error] --> tests/fail/function_calls/check_arg_count_too_many_args.rs:7:42
  |
7 |         let _ = malloc(1, 2); //~ ERROR: Undefined Behavior: incorrect number of arguments for `malloc`: got 2, expected 1
  |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
  |

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/function_calls/check_arg_count_too_many_args.rs:3:9
  |
3 |         fn malloc(_: i32, _: i32) -> *mut std::ffi::c_void;
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[invalid_runtime_symbol_definitions]: invalid definition of the runtime `malloc` symbol used by the standard library
  |

full stderr:
error: invalid definition of the runtime `malloc` symbol used by the standard library
##[error]  --> tests/fail/function_calls/check_arg_count_too_many_args.rs:3:9
   |
LL |         fn malloc(_: i32, _: i32) -> *mut std::ffi::c_void;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `unsafe extern "C" fn(i32, i32) -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = note: `#[deny(invalid_runtime_symbol_definitions)]` on by default

error: aborting due to 1 previous error


full stdout:



FAILED TEST: tests/fail/function_calls/exported_symbol_shim_clashing.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/function_calls" "tests/fail/function_calls/exported_symbol_shim_clashing.rs" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/function_calls/exported_symbol_shim_clashing.stderr` to the actual output
--- tests/fail/function_calls/exported_symbol_shim_clashing.stderr
+++ <stderr output>
-error: found `malloc` symbol definition that clashes with a built-in shim
+error: suspicious definition of the runtime `malloc` symbol used by the standard library
   --> tests/fail/function_calls/exported_symbol_shim_clashing.rs:LL:CC
    |
-LL |         malloc(0);
+LL | extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
-   |         ^^^^^^^^^ error occurred here
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-help: the `malloc` symbol is defined here
-  --> tests/fail/function_calls/exported_symbol_shim_clashing.rs:LL:CC
-   |
-LL | / extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
-LL | |
-LL | |     unreachable!()
-LL | | }
-   | |_^
+   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
+           found    `extern "C" fn(usize) -> *mut std::ffi::c_void`
+   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
+   = help: allow this lint if the signature is compatible
+   = note: `-D suspicious-runtime-symbol-definitions` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(suspicious_runtime_symbol_definitions)]`
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
---
Full unnormalized output:
error: suspicious definition of the runtime `malloc` symbol used by the standard library
##[error]  --> tests/fail/function_calls/exported_symbol_shim_clashing.rs:2:1
   |
LL | extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `extern "C" fn(usize) -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = help: allow this lint if the signature is compatible
   = note: `-D suspicious-runtime-symbol-definitions` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(suspicious_runtime_symbol_definitions)]`

error: aborting due to 1 previous error
---
3 |     //~^ HELP: the `malloc` symbol is defined here
  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
  |

error: `found `malloc` symbol definition that clashes with a built-in shim` not found in diagnostics on line 12
##[error]  --> tests/fail/function_calls/exported_symbol_shim_clashing.rs:13:21
   |
13 |         //~^ ERROR: found `malloc` symbol definition that clashes with a built-in shim
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
   |

error: there were 4 unmatched diagnostics
##[error] --> tests/fail/function_calls/exported_symbol_shim_clashing.rs:2:1
  |
2 | extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  | |
  | Error[suspicious_runtime_symbol_definitions]: suspicious definition of the runtime `malloc` symbol used by the standard library
  | Help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
  | Help: allow this lint if the signature is compatible
  | Help: to override `-D warnings` add `#[allow(suspicious_runtime_symbol_definitions)]`
  |

full stderr:
error: suspicious definition of the runtime `malloc` symbol used by the standard library
##[error]  --> tests/fail/function_calls/exported_symbol_shim_clashing.rs:2:1
   |
LL | extern "C" fn malloc(_: usize) -> *mut std::ffi::c_void {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(usize) -> *mut std::ffi::c_void`
           found    `extern "C" fn(usize) -> *mut std::ffi::c_void`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "malloc")]`, or `#[link_name = "malloc"]`
   = help: allow this lint if the signature is compatible
   = note: `-D suspicious-runtime-symbol-definitions` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(suspicious_runtime_symbol_definitions)]`

error: aborting due to 1 previous error


full stdout:



FAILED TEST: tests/fail/shims/input_arg_mismatch.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/shims" "tests/fail/shims/input_arg_mismatch.rs" "-Zmiri-disable-isolation" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/shims/input_arg_mismatch.stderr` to the actual output
--- tests/fail/shims/input_arg_mismatch.stderr
+++ <stderr output>
-error: Undefined Behavior: calling a function whose parameter #1 has type i32 passing argument of type u32
+error: suspicious definition of the runtime `close` symbol used by the standard library
   --> tests/fail/shims/input_arg_mismatch.rs:LL:CC
    |
-LL |         close(fd);
+LL |     fn close(fd: u32) -> c_int;
-   |         ^^^^^^^^^ Undefined Behavior occurred here
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
-   = help: this means these two types are not *guaranteed* to be ABI-compatible across all targets
-   = help: if you think this code should be accepted anyway, please report an issue with Miri
+   = note: expected `unsafe extern "C" fn(i32) -> i32`
+           found    `unsafe extern "C" fn(u32) -> i32`
+   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]`
+   = help: allow this lint if the signature is compatible
+   = note: `-D suspicious-runtime-symbol-definitions` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(suspicious_runtime_symbol_definitions)]`
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
---
Full unnormalized output:
error: suspicious definition of the runtime `close` symbol used by the standard library
##[error]  --> tests/fail/shims/input_arg_mismatch.rs:9:5
   |
LL |     fn close(fd: u32) -> c_int;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(i32) -> i32`
           found    `unsafe extern "C" fn(u32) -> i32`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]`
---

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/shims/input_arg_mismatch.rs:9:5
  |
9 |     fn close(fd: u32) -> c_int;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[suspicious_runtime_symbol_definitions]: suspicious definition of the runtime `close` symbol used by the standard library
  |

full stderr:
error: suspicious definition of the runtime `close` symbol used by the standard library
##[error]  --> tests/fail/shims/input_arg_mismatch.rs:9:5
   |
LL |     fn close(fd: u32) -> c_int;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(i32) -> i32`
           found    `unsafe extern "C" fn(u32) -> i32`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]`
---



FAILED TEST: tests/fail/shims/non_vararg_signature_mismatch.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/shims" "tests/fail/shims/non_vararg_signature_mismatch.rs" "-Zmiri-disable-isolation" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/shims/non_vararg_signature_mismatch.stderr` to the actual output
--- tests/fail/shims/non_vararg_signature_mismatch.stderr
+++ <stderr output>
-error: Undefined Behavior: calling a variadic function with a non-variadic caller-side signature
+error: invalid definition of the runtime `open` symbol used by the standard library
   --> tests/fail/shims/non_vararg_signature_mismatch.rs:LL:CC
    |
-LL |         open(c_path.as_ptr(), /* value does not matter */ 0)
+LL |     fn open(path: *const c_char, oflag: c_int) -> c_int;
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
+   = note: expected `unsafe extern "C" fn(*const i8, i32, ...) -> i32`
---
Full unnormalized output:
error: invalid definition of the runtime `open` symbol used by the standard library
##[error]  --> tests/fail/shims/non_vararg_signature_mismatch.rs:8:5
   |
LL |     fn open(path: *const c_char, oflag: c_int) -> c_int;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(*const i8, i32, ...) -> i32`
           found    `unsafe extern "C" fn(*const i8, i32) -> i32`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "open")]`, or `#[link_name = "open"]`
---

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/shims/non_vararg_signature_mismatch.rs:8:5
  |
8 |     fn open(path: *const c_char, oflag: c_int) -> c_int;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[invalid_runtime_symbol_definitions]: invalid definition of the runtime `open` symbol used by the standard library
  |

full stderr:
error: invalid definition of the runtime `open` symbol used by the standard library
##[error]  --> tests/fail/shims/non_vararg_signature_mismatch.rs:8:5
   |
LL |     fn open(path: *const c_char, oflag: c_int) -> c_int;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(*const i8, i32, ...) -> i32`
           found    `unsafe extern "C" fn(*const i8, i32) -> i32`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "open")]`, or `#[link_name = "open"]`
---



FAILED TEST: tests/fail/shims/return_type_mismatch.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/shims" "tests/fail/shims/return_type_mismatch.rs" "-Zmiri-disable-isolation" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/shims/return_type_mismatch.stderr` to the actual output
--- tests/fail/shims/return_type_mismatch.stderr
+++ <stderr output>
-error: Undefined Behavior: calling a function with return type i32 passing return place of type i16
+error: suspicious definition of the runtime `close` symbol used by the standard library
   --> tests/fail/shims/return_type_mismatch.rs:LL:CC
    |
-LL |         close(fd);
+LL |     fn close(fd: c_int) -> c_short;
-   |         ^^^^^^^^^ Undefined Behavior occurred here
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
-   = help: this means these two types are not *guaranteed* to be ABI-compatible across all targets
-   = help: if you think this code should be accepted anyway, please report an issue with Miri
+   = note: expected `unsafe extern "C" fn(i32) -> i32`
+           found    `unsafe extern "C" fn(i32) -> i16`
+   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]`
+   = help: allow this lint if the signature is compatible
+   = note: `-D suspicious-runtime-symbol-definitions` implied by `-D warnings`
+   = help: to override `-D warnings` add `#[allow(suspicious_runtime_symbol_definitions)]`
 
-note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
---
Full unnormalized output:
error: suspicious definition of the runtime `close` symbol used by the standard library
##[error]  --> tests/fail/shims/return_type_mismatch.rs:9:5
   |
LL |     fn close(fd: c_int) -> c_short;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(i32) -> i32`
           found    `unsafe extern "C" fn(i32) -> i16`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]`
---
error: aborting due to 1 previous error



error: `calling a function with return type i32 passing return place of type i16` not found in diagnostics on line 18
##[error]  --> tests/fail/shims/return_type_mismatch.rs:19:21
   |
19 |         //~^ ERROR: calling a function with return type i32 passing return place of type i16
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected because of this pattern
   |

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/shims/return_type_mismatch.rs:9:5
  |
9 |     fn close(fd: c_int) -> c_short;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[suspicious_runtime_symbol_definitions]: suspicious definition of the runtime `close` symbol used by the standard library
  |

full stderr:
error: suspicious definition of the runtime `close` symbol used by the standard library
##[error]  --> tests/fail/shims/return_type_mismatch.rs:9:5
   |
LL |     fn close(fd: c_int) -> c_short;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected `unsafe extern "C" fn(i32) -> i32`
           found    `unsafe extern "C" fn(i32) -> i16`
   = help: either fix the signature or remove any attributes like `#[unsafe(no_mangle)]`, `#[unsafe(export_name = "close")]`, or `#[link_name = "close"]`
---



FAILED TEST: tests/fail/shims/wrong_fixed_arg_count.rs
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-rQY1Hl" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/fail/shims" "tests/fail/shims/wrong_fixed_arg_count.rs" "-Zmiri-disable-isolation" "--edition" "2021"

error: actual output differed from expected
Execute `./miri test --bless` to update `tests/fail/shims/wrong_fixed_arg_count.stderr` to the actual output
--- tests/fail/shims/wrong_fixed_arg_count.stderr
+++ <stderr output>
-error: Undefined Behavior: incorrect number of fixed arguments for variadic function `open`: got 1, expected 2
+error: invalid definition of the runtime `open` symbol used by the standard library
   --> tests/fail/shims/wrong_fixed_arg_count.rs:LL:CC
    |
-LL |         open(c_path.as_ptr(), /* value does not matter */ 0)
+LL |     fn open(path: *const c_char, ...) -> c_int;
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Undefined Behavior occurred here
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
-   = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
+   = note: expected `unsafe extern "C" fn(*const i8, i32, ...) -> i32`
---

error: there was 1 unmatched diagnostic
##[error] --> tests/fail/shims/wrong_fixed_arg_count.rs:7:5
  |
7 |     fn open(path: *const c_char, ...) -> c_int;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error[invalid_runtime_symbol_definitions]: invalid definition of the runtime `open` symbol used by the standard library
  |

full stderr:
error: invalid definition of the runtime `open` symbol used by the standard library
##[error]  --> tests/fail/shims/wrong_fixed_arg_count.rs:7:5
---
Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.7/src/lib.rs:365

  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   1: <color_eyre[8436065311fa66f6]::config::EyreHook>::into_eyre_hook::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   2: eyre[be3e0da1a29bd683]::capture_handler<unknown>
      at <unknown source file>:<unknown line>
   3: eyre[be3e0da1a29bd683]::private::format_err<unknown>
      at <unknown source file>:<unknown line>
   4: ui_test[4674b401a1a0501d]::run_tests_generic::<ui_test[4674b401a1a0501d]::default_file_filter, ui[6eb12e50997f5678]::run_tests::{closure#1}, alloc[bfa8ea96d3e1b588]::boxed::Box<dyn ui_test[4674b401a1a0501d]::status_emitter::StatusEmitter>><unknown>
      at <unknown source file>:<unknown line>
   5: ui[6eb12e50997f5678]::ui<unknown>
      at <unknown source file>:<unknown line>
   6: ui[6eb12e50997f5678]::main<unknown>
      at <unknown source file>:<unknown line>
   7: std[a83598ed769ac6bb]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[f5ebec6e9c650de3]::result::Result<(), eyre[be3e0da1a29bd683]::Report>, core[f5ebec6e9c650de3]::result::Result<(), eyre[be3e0da1a29bd683]::Report>><unknown>
      at <unknown source file>:<unknown line>
   8: std[a83598ed769ac6bb]::rt::lang_start::<core[f5ebec6e9c650de3]::result::Result<(), eyre[be3e0da1a29bd683]::Report>>::{closure#0}<unknown>
      at <unknown source file>:<unknown line>
   9: std[a83598ed769ac6bb]::rt::lang_start_internal<unknown>
      at <unknown source file>:<unknown line>
  10: main<unknown>
      at <unknown source file>:<unknown line>
  11: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  12: _start<unknown>
      at <unknown source file>:<unknown line>

Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/miri/b44484fea07e790a/out/ui-b44484fea07e790a` (exit status: 1)
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo test --target x86_64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color=always --profile=release --manifest-path /checkout/src/tools/miri/Cargo.toml -- [workdir=/checkout]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:191:21
Executed at: src/bootstrap/src/core/build_steps/test.rs:769:19

--- BACKTRACE vvv
   0: <bootstrap::utils::exec::DeferredCommand>::finish_process
             at /checkout/src/bootstrap/src/utils/exec.rs:939:17
   1: <bootstrap::utils::exec::DeferredCommand>::wait_for_output::<&bootstrap::utils::exec::ExecutionContext>
             at /checkout/src/bootstrap/src/utils/exec.rs:831:21
   2: <bootstrap::utils::exec::ExecutionContext>::run
             at /checkout/src/bootstrap/src/utils/exec.rs:741:45
   3: <bootstrap::utils::exec::BootstrapCommand>::run::<&bootstrap::core::builder::Builder>
             at /checkout/src/bootstrap/src/utils/exec.rs:339:27
   4: <bootstrap::core::build_steps::test::Miri as bootstrap::core::builder::Step>::run
             at /checkout/src/bootstrap/src/core/build_steps/test.rs:769:19
   5: <bootstrap::core::builder::Builder>::ensure::<bootstrap::core::build_steps::test::Miri>
             at /checkout/src/bootstrap/src/core/builder/mod.rs:1597:36
   6: <bootstrap::core::build_steps::test::Miri as bootstrap::core::builder::Step>::make_run
             at /checkout/src/bootstrap/src/core/build_steps/test.rs:695:21
   7: <bootstrap::core::builder::StepDescription>::maybe_run
             at /checkout/src/bootstrap/src/core/builder/mod.rs:476:13
   8: bootstrap::core::builder::cli_paths::match_paths_to_steps_and_run
             at /checkout/src/bootstrap/src/core/builder/cli_paths.rs:232:18
   9: <bootstrap::core::builder::Builder>::run_step_descriptions
             at /checkout/src/bootstrap/src/core/builder/mod.rs:1140:9
  10: <bootstrap::core::builder::Builder>::execute_cli
             at /checkout/src/bootstrap/src/core/builder/mod.rs:1119:14
  11: <bootstrap::Build>::build
             at /checkout/src/bootstrap/src/lib.rs:803:25
  12: bootstrap::main
             at /checkout/src/bootstrap/src/bin/main.rs:130:11
  13: <fn() as core::ops::function::FnOnce<()>>::call_once
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/core/src/ops/function.rs:250:5
  14: std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/sys/backtrace.rs:166:18
  15: std::rt::lang_start::<()>::{closure#0}
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/rt.rs:206:18
  16: <&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe as core::ops::function::FnOnce<()>>::call_once
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/core/src/ops/function.rs:287:21
  17: std::panicking::catch_unwind::do_call::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/panicking.rs:581:40
  18: std::panicking::catch_unwind::<i32, &dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe>
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/panicking.rs:544:19
  19: std::panic::catch_unwind::<&dyn core::ops::function::Fn<(), Output = i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe, i32>
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/panic.rs:359:14
  20: std::rt::lang_start_internal::{closure#0}
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/rt.rs:175:24
  21: std::panicking::catch_unwind::do_call::<std::rt::lang_start_internal::{closure#0}, isize>
             at /rustc/0417c25868d6dfbd1c291dfeae950504faa6f790/library/std/src/panicking.rs:581:40
---
  28: __libc_start_main
  29: _start


Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test --stage 2 src/tools/miri src/tools/miri/cargo-miri`
Build completed unsuccessfully in 0:48:46
  local time: Sun Jun 28 13:36:38 UTC 2026
  network time: Sun, 28 Jun 2026 13:36:38 GMT
##[error]Process completed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-nominated Nominated for discussion during a lang team meeting. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants