H-uru / libhsplasma

Cross-platform Plasma data and network library
GNU General Public License v3.0
32 stars 30 forks source link

Use Win32 API in `hsFileStream`. #242

Closed Hoikas closed 2 years ago

Hoikas commented 2 years ago

When developing Korman's "Test Age" feature, I noticed a curious bug that I could never quite understand. The feature basically uses hsFileStream to modify the TPotS vault.dat, then launches Uru. Occassionally, however, Uru would act as if the changes to the vault were not made - but according to VaultShop, the changes were present! I discovered that adding a small sleep between writing vault.dat and launching Uru made the process slightly more reliable, but still not 100%.

As it turns out, the C file API in Windows is evidentally vulnerable to race conditions where changes are not flushed out as expected. I'm not mthe only one to discover this problem: https://twitter.com/jonathan_blow/status/1417544504916135936