Make memfile offset atomic so checkdisk() can read it from other threads

checkdisk() is called from the parsing threads and sums the write
positions of every reader. The geometry/index/vertex/node positions were
already std::atomic, but memfile::off (the string pool and tree sizes)
was a plain size_t that the owning thread updates in memfile_write(),
which ThreadSanitizer reports as a data race.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfWkLhwEvKQoNGVPsLGehj
This commit is contained in:
Claude
2026-09-26 17:00:11 +00:00
parent 4f2621186a
commit 6e78110000
+2 -1
View File
@@ -10,7 +10,8 @@ struct memfile {
std::string map; std::string map;
unsigned long tree = 0; unsigned long tree = 0;
FILE *fp = NULL; FILE *fp = NULL;
size_t off = 0; // Read by checkdisk() from other threads while the owning reader thread appends
std::atomic<size_t> off{0};
}; };
struct memfile *memfile_open(int fd); struct memfile *memfile_open(int fd);