-
Notifications
You must be signed in to change notification settings - Fork 394
Description
rust-lang/rust#113113 fixed some bugs in ZST handling of the core collections. I wonder if there is a way that Miri could help find those bugs?
Unfortunately the Rust global allocator says that allocating ZST is UB, so when the collections use the global allocator then ZST allocations never reach Miri -- or put differently, there's not actually a bug with Vec<T, Global>
. So I guess to detect this we'd have to explicitly use Vec<T, System>
? Then we could make the Miri implementation of malloc actually create a new (zero-sized) allocation on malloc(0)
, and so failing to pass that to free
would be a leak. Passing a dangling pointer to free
is already UB (except if it is NULL) so we should also be able to detect that case.
However, currently I don't think that would help. System::alloc
ends up here so we never end up even calling malloc(0)
. I guess we'd need our own allocator for this test that wraps malloc
more directly?