CFI: Fn closure called through dyn FnMut fails the CFI check
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 47/100
調査の方向性
Start by reproducing the minimal example with the nightly rustc command and CFI flags shown in the issue, then read the referenced Rust issues #144641 and #160230 for related context. The report identifies a mismatch in the CFI check for a closure called through dyn FnMut, but does not name the compiler source files or tests involved. Done means the reduced example runs without the CFI failure and a regression test covers it.
索引モデルが issue の本文から書いたものです。
説明
Found when running ClickHouse with CFI which includes the ipnet crate, version 2.12.0:
contrib/rust_vendor/ipnet-2.12.0/src/lib.rs:1:1: runtime error: control flow integrity check for type
fn(&mut dyn for<'a, 'b> FnMut(&'a mut parser::Parser<'b>) -> Option<ipnet::IpNet>, &mut parser::Parser<'_>) -> Option<ipnet::IpNet>
failed during indirect function call
note: <<ipnet::parser::Parser>::read_ip_net::{closure#0} as FnOnce<(&mut ipnet::parser::Parser,)>>::call_once::{shim:vtable#0} defined here
Original code in ipnet but it's reduced to this code:
fn main() {
let f = || std::env::args().count();
let mut b: Box<dyn FnMut() -> usize> = Box::new(f);
println!("{}", b());
}
I expected to see only the expected line (1), instead the binary crashes with SIGILL or, if we change cfi to show the warning instead of crashing, it shows a warning:
$ rustc +nightly --edition=2021 -Copt-level=1 -Clto -Ccodegen-units=1 \
-Zsanitizer=cfi -Zsanitizer-cfi-diag -Zsanitizer-cfi-recover \
-Cunsafe-allow-abi-mismatch=sanitizer fn_as_fnmut.rs
$ ./fn_as_fnmut
fn_as_fnmut.rs:1:1: runtime error: control flow integrity check for type fn(&mut dyn std::ops::FnMut() -> usize) -> usize failed during indirect function call
fn_as_fnmut.625fcbea4de00cd8-cgu.0: note: fn_as_fnmut::main::{closure#0} defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior fn_as_fnmut.rs:1:1
1
It seems related to https://github.com/rust-lang/rust/issues/144641 cc @rcvalle
https://github.com/rust-lang/rust/pull/160230 also looks related, but the repro fails with and without it
Meta
rustc --version --verbose:
$ rustc +nightly --version --verbose
rustc 1.102.0-nightly (5f4effd57 2026-11-13)
binary: rustc
commit-hash: 5f4effd579500175af844241eb179e756190f1e7
commit-date: 2026-11-13
host: x86_64-unknown-linux-gnu
release: 1.102.0-nightly
LLVM version: 23.1.5
Also tested with:
nightly-2024-04-01nightly-2025-06-01- And
stable 1.100.0 (2026-11-09), with RUSTC_BOOTSTRAP=1
Backtrace
Core was generated by `./fn_as_fnmut'.
Program terminated with signal SIGILL, Illegal instruction.
#0 0x0000562447661b6e in fn_as_fnmut::main ()
(gdb) bt
#0 0x0000562447661b6e in fn_as_fnmut::main ()
#1 0x0000562447661b42 in std::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()> ()
#2 0x0000562447661b59 in std::rt::lang_start::<()>::{closure#0} ()
#3 0x000056244769abd6 in core::ops::function::impls::{impl#2}::call_once<(), (dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)>
() at library/core/src/ops/function.rs:287
#4 std::panicking::catch_unwind::do_call<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> ()
at library/std/src/panicking.rs:573
#5 std::panicking::catch_unwind<i32, &(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe)> () at library/std/src/panicking.rs:541
#6 std::panic::catch_unwind<&(dyn core::ops::function::Fn<(), Output=i32> + core::marker::Sync + core::panic::unwind_safe::RefUnwindSafe), i32> () at library/std/src/panic.rs:359
#7 std::rt::lang_start_internal::{closure#0} () at library/std/src/rt.rs:175
#8 std::panicking::catch_unwind::do_call<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panicking.rs:573
#9 std::panicking::catch_unwind<isize, std::rt::lang_start_internal::{closure_env#0}> () at library/std/src/panicking.rs:541
#10 std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#0}, isize> () at library/std/src/panic.rs:359
#11 std::rt::lang_start_internal () at library/std/src/rt.rs:171
#12 0x0000562447661b94 in main ()
- 主要言語
- Rust
- スター
- 122k
- フォーク
- 16.7k
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 515
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rust-lang/rust のほかの issue
-
Remove unnecessary parentheses when suggesting to remove '&' from a pattern対応中かも @BartSimpson001 が 1 日前に担当しました。 オープンA-diagnostics D-invalid-suggestion T-compiler
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Windows `File::set_permissions` silently does nothing when clearing `readonly` leaves `FileAttributes == 0`対応中かも @ChrisDenton が 11 日前に担当しました。 オープンA-filesystem C-bug O-windows T-libs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
rust-lang/rust#165504 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
relnotes relnotes-tracking-issue T-libs
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
bytecodealliance/wrpc#1785 ·
メンテナーはふだん 1 日以内に返信
-
2 advisory ignore entries no longer match anything (`quick-xml` already patched in `Cargo.lock`)オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
longbridge/nsh#2758 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
antithesishq/bombadil#473 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
libracoder/kiri#669 ·
メンテナーはふだん 1 日以内に返信