Skip to content

Instantly share code, notes, and snippets.

@BoxyUwU
Created March 27, 2025 17:51
Show Gist options
  • Save BoxyUwU/dc70ec5215c10a807afcec2970df316d to your computer and use it in GitHub Desktop.
Save BoxyUwU/dc70ec5215c10a807afcec2970df316d to your computer and use it in GitHub Desktop.
test recorder::tests::unsoundness ... error: Undefined Behavior: constructing invalid value: encountered a dangling reference (use-after-free)
--> metrics/src/recorder/mod.rs:264:17
|
264 | dbg!(self.0);
| ^^^^^^^^^^^^ constructing invalid value: encountered a dangling reference (use-after-free)
|
= 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: BACKTRACE on thread `recorder::tests`:
= note: inside `<recorder::tests::unsoundness::Foo<'_> as recorder::Recorder>::describe_counter` at /home/boxy/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/macros.rs:364:13: 364:16
note: inside closure
--> metrics/src/recorder/mod.rs:315:29
|
315 | with_recorder(|rec| rec.describe_counter(KeyName::from_const_str(""), None, "".into()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> metrics/src/recorder/mod.rs:234:22
|
234 | unsafe { f(recorder.as_ref()) }
| ^^^^^^^^^^^^^^^^^^^^
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<std::ptr::NonNull<dyn recorder::Recorder>>>>::try_with::<{closure@metrics/src/recorder/mod.rs:228:25: 228:41}, ()>` at /home/boxy/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:311:12: 311:27
= note: inside `std::thread::LocalKey::<std::cell::Cell<std::option::Option<std::ptr::NonNull<dyn recorder::Recorder>>>>::with::<{closure@metrics/src/recorder/mod.rs:228:25: 228:41}, ()>` at /home/boxy/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:275:15: 275:31
note: inside `recorder::with_recorder::<(), {closure@metrics/src/recorder/mod.rs:315:23: 315:28}>`
--> metrics/src/recorder/mod.rs:228:5
|
228 | / LOCAL_RECORDER.with(|local_recorder| {
229 | | if let Some(recorder) = local_recorder.get() {
... |
240 | | })
| |______^
note: inside `recorder::tests::unsoundness`
--> metrics/src/recorder/mod.rs:315:9
|
315 | with_recorder(|rec| rec.describe_counter(KeyName::from_const_str(""), None, "".into()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: inside closure
--> metrics/src/recorder/mod.rs:254:21
|
253 | #[test]
| ------- in this procedural macro expansion
254 | fn unsoundness() {
| ^
= note: this error originates in the macro `dbg` which comes from the expansion of the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
error: aborting due to 1 previous error; 15 warnings emitted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment