Opened 2 hours ago
#147 new defect
survexport doesn't flush csv files on windows
| Reported by: | Philip Schuchardt | Owned by: | Olly Betts |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | aven | Version: | 1.4.19 |
| Keywords: | Cc: |
Description
Problem: On Windows the exported CSV can appear “missing” or partially written immediately after survexport exits because the MinGW-compiled binary (used in the release under C:/Program Files (x86)/Survex) leaves its FILE* buffers cached and doesn’t FlushFileBuffers?. The next task in CaveWhere? races ahead and sees a zero/partial-length file even though the process has closed. Native MSVC builds don’t exhibit this because the MSVC CRT already flushes at fclose(). Full csv file write can take more than 500ms after survexport is closed with the official build.
Expected: When survexport exits it should FlushFileBuffers? (or open with write-through) so downstream tasks see the final file quickly.
Diagnosis: The official release build lacks the explicit flush; the MSVC-built version does not show the race.
Impact: Export/CSV parsing tasks occasionally fail or read incomplete data on Windows installations using the standard Survex release. I have code in CaveWhere? to reduce this issue for the official release, but I'm shipping CaveWhere? with MSVC build that doesn't' have this flushing problem. This is pretty low priority, unless people are using survexport in some data processing pipeline on windows.
I'm not sure if cavern has this same problem, but I've only observed it in survexport.
