From 9948716be851e87b7efd9277603bc2fd06159d55 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Jan 2026 18:48:23 +0000 Subject: [PATCH] Fix assertion failure in file_tree_read when read operation fails Initialize *gen to NO_GENERATION at the start of file_tree_read so that error paths (FILETREE_BADPATH, FILETREE_NOENT, FILETREE_ISDIR) have a well-defined value. Previously, when file_tree_read failed, gen was uninitialized, causing the assertion in process_client_read to fire. The assertion checking gen != NO_GENERATION before the error check was removed since: 1. On error paths, gen is not used 2. On success paths, the assertion at line 482 already validates gen --- src/file_tree.c | 3 +++ src/metadata_server.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/file_tree.c b/src/file_tree.c index 6bf36b3..1abfb7a 100644 --- a/src/file_tree.c +++ b/src/file_tree.c @@ -513,6 +513,9 @@ int file_tree_read(FileTree *ft, string path, uint64_t off, uint64_t len, uint64_t *gen, uint64_t *chunk_size, SHA256 *hashes, int max_hashes, uint64_t *actual_bytes) { + // Initialize gen to NO_GENERATION so error paths have a well-defined value + *gen = NO_GENERATION; + int num_comps; string comps[MAX_COMPS]; diff --git a/src/metadata_server.c b/src/metadata_server.c index 8e2d6b9..1354c78 100644 --- a/src/metadata_server.c +++ b/src/metadata_server.c @@ -432,7 +432,6 @@ process_client_read(MetadataServer *state, int conn_idx, ByteView msg) uint64_t actual_bytes; SHA256 hashes[MAX_READ_HASHES]; int ret = file_tree_read(&state->file_tree, path, offset, length, &gen, &chunk_size, hashes, MAX_READ_HASHES, &actual_bytes); - assert(gen != NO_GENERATION); if (ret < 0) {