Closed WhyNotHugo closed 1 year ago
With current main
, this yields:
Replacing unreferenced package with stub: windows_x86_64_gnullvm
Replacing unreferenced package with stub: windows_x86_64_msvc
Replacing unreferenced package with stub: android_system_properties
thread 'main' panicked at 'assertion failed: unreferenced.insert(name.to_string())', src/main.rs:707:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I'm honestly having a really hard time trying to figure out this function (it's over 200LOC).
Looks like what's going on here is that a package is being replaced with a stub, and there's an assertion to confirm that the same package has not been visited before. In particular, android_system_properties
seems to get visited twice, even though it's a single iteration of read_dir
. I wonder how ReadDir
behaves when the directory is mutated during the iteration.
Yeah, this is undefined behaviour:
If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified.
So I think what's happening here is that the underlying filesystem is mutated while iterating over the iterator returned by readdir
, this seems to be undefined behaviour. In particular, it seems this results in the same file being returned more than twice.
I think the solution is to read all the entries into memory and then process them. I'll try and come up with a patch.
My
Cargo.toml is this one
plus: