You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use ouroboros::self_referencing;#[self_referencing]structStringCell{owner:Box<String>,#[borrows(owner)]dependent:&'this String,}fnmain(){let _ = StringCellBuilder{owner:Box::new("some string into".into()),dependent_builder: |_| todo!(),}.build();}
And running it with miri:
$ cargo +nightly miri run
I get:
thread 'main' panicked at 'not yet implemented', src/main.rs:14:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The following memory was leaked: alloc1433 (Rust heap, size: 16, align: 1) {
73 6f 6d 65 20 73 74 72 69 6e 67 20 69 6e 74 6f │ some string into
}
alloc1503 (Rust heap, size: 24, align: 8) {
0x00 │ ╾alloc1433[<untagged>]╼ 10 00 00 00 00 00 00 00 │ ╾──────╼........
0x10 │ 10 00 00 00 00 00 00 00 │ ........
}
error: the evaluated program leaked memory
error: aborting due to previous error
Per se leaking is safe to do, but at least you should document it. I looked through the documentation and could not find any mention of it.
This came up in a discussion about self_cell and I've since revised my stance and switched from documenting the possible leak and providing an example that shows how to prevent it with catch_unwind, to handling the leak with a scope guard Voultapher/self_cell@d457300
The text was updated successfully, but these errors were encountered:
Thanks for bringing this up. For now I've added a note to the documentation for 0.9.5, if I have some more time I'll look into how I can use the approach you linked to aovid this behavior altogether.
Given this program, and ouroboros 0.9:
And running it with miri:
I get:
Per se leaking is safe to do, but at least you should document it. I looked through the documentation and could not find any mention of it.
This came up in a discussion about self_cell and I've since revised my stance and switched from documenting the possible leak and providing an example that shows how to prevent it with catch_unwind, to handling the leak with a scope guard Voultapher/self_cell@d457300
The text was updated successfully, but these errors were encountered: