From c2779a73e93dec6be196594817ca88984f801b12 Mon Sep 17 00:00:00 2001 From: Eylon Krause Date: Wed, 24 Jun 2026 18:11:58 +0300 Subject: [PATCH] telemetry: don't unlink the producer's file when attaching fails sharedRingBuffer::openCyclicBuffer() is the reader/attach path (create=false), but on two error branches it unlink()s the shared-memory file it only opened: header mmap failure and version mismatch. A reader built from a different NIXL version (or attaching to an exporter file from an older run) therefore deletes the producer agent's live telemetry file from the filesystem. The reader's other two error paths -- "File too small for buffer data" and the final whole-buffer mmap failure -- already only munmap and throw without unlinking, so this just makes all of openCyclicBuffer consistent: a reader never removes a file it did not create. The unlink()s in createCyclicBuffer() (the create=true path) are correct and left unchanged -- a creator may remove a file it just made. The file_fd unique-ptr still closes the descriptor on the error path. Signed-off-by: Eylon Krause --- src/utils/common/cyclic_buffer.tpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils/common/cyclic_buffer.tpp b/src/utils/common/cyclic_buffer.tpp index d3071a36ce..aecd2042c3 100644 --- a/src/utils/common/cyclic_buffer.tpp +++ b/src/utils/common/cyclic_buffer.tpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -208,7 +208,6 @@ sharedRingBuffer::openCyclicBuffer(const std::string &name, int version) { void *header_ptr = mmap(nullptr, sizeof(bufferHeader), PROT_READ | PROT_WRITE, MAP_SHARED, *file_fd, 0); if (header_ptr == MAP_FAILED) { - unlink(name.c_str()); NIXL_ERROR << "Failed to map header memory: " << name << " with error: " << strerror(errno); throw std::runtime_error("Failed to map header memory"); @@ -220,7 +219,6 @@ sharedRingBuffer::openCyclicBuffer(const std::string &name, int version) { int current_version = temp_header->version.load(std::memory_order_acquire); if (current_version != version) { munmap(temp_header, sizeof(bufferHeader)); - unlink(name.c_str()); NIXL_ERROR << "Version mismatch: expected " + std::to_string(version) + ", got " + std::to_string(current_version); throw std::runtime_error("Version mismatch: expected " + std::to_string(version) +