From 6e78110000d2b5be5b48ec662c597f5094622b97 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 26 Sep 2026 17:00:11 +0000 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01EfWkLhwEvKQoNGVPsLGehj --- memfile.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/memfile.hpp b/memfile.hpp index e339120d..8e34a4a7 100644 --- a/memfile.hpp +++ b/memfile.hpp @@ -10,7 +10,8 @@ struct memfile { std::string map; unsigned long tree = 0; FILE *fp = NULL; - size_t off = 0; + // Read by checkdisk() from other threads while the owning reader thread appends + std::atomic off{0}; }; struct memfile *memfile_open(int fd);