Answers checklist.
IDF version.
ESP-IDF 5.4.0+
Espressif SoC revision.
All
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
Does not matter
Power Supply used.
USB
What is the expected behavior?
#10220's fix (e17da6f, v5.4.0+) put a single-entry readdir→stat cache in the per-mount vfs_fat_ctx_t instead of the per-stream vfs_fat_dir_t.
Furthermore, this cache is accessed without fat_ctx->lock and never invalidated by unlink/rename/truncate breaking POSIX readdir cross-stream thread-safety.
This was originally found by @joboet in the Rust STD impl for the ESP-IDF, in issue rust-lang/rust#158727.
The workaround STD did for now is that the ESP-IDF target would stay on readdir_r
Note that this cache would likely be returning wrong stat results even single-threaded when two directories are open at once (?!). So this is not just about "faithfully implementing the readdir multi-threading contract".
Unless I'm missing something, the error is pretty severe.
What is the actual behavior?
See above
Steps to reproduce.
As per above - should be triggered by many cases. The simplest being two directories opened for reading simultaneously.
Debug Logs.
Diagnostic report archive.
No response
More Information.
No response
Answers checklist.
IDF version.
ESP-IDF 5.4.0+
Espressif SoC revision.
All
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
Does not matter
Power Supply used.
USB
What is the expected behavior?
#10220's fix (e17da6f, v5.4.0+) put a single-entry
readdir→statcache in the per-mountvfs_fat_ctx_tinstead of the per-streamvfs_fat_dir_t.Furthermore, this cache is accessed without
fat_ctx->lockand never invalidated byunlink/rename/truncatebreaking POSIXreaddircross-stream thread-safety.This was originally found by @joboet in the Rust STD impl for the ESP-IDF, in issue rust-lang/rust#158727.
The workaround STD did for now is that the ESP-IDF target would stay on
readdir_rNote that this cache would likely be returning wrong stat results even single-threaded when two directories are open at once (?!). So this is not just about "faithfully implementing the
readdirmulti-threading contract".Unless I'm missing something, the error is pretty severe.
What is the actual behavior?
See above
Steps to reproduce.
As per above - should be triggered by many cases. The simplest being two directories opened for reading simultaneously.
Debug Logs.
Diagnostic report archive.
No response
More Information.
No response