From a461b72ae77ca27f4266136d478e6fd2b81ee187 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Wed, 14 Jan 2026 22:36:56 +0000 Subject: [PATCH] fix: clean up semaphore if thread spawn fails When std.Thread.spawn fails in the install() function, the semaphore that was already initialized needs to be cleaned up to prevent a resource leak. The C++ Bun::Semaphore object allocated by init() would otherwise never be destroyed. Co-Authored-By: Claude Opus 4.5 --- src/bun.js/event_loop/RuntimeInspector.zig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bun.js/event_loop/RuntimeInspector.zig b/src/bun.js/event_loop/RuntimeInspector.zig index fd3170d10b..350a5afa4d 100644 --- a/src/bun.js/event_loop/RuntimeInspector.zig +++ b/src/bun.js/event_loop/RuntimeInspector.zig @@ -160,6 +160,8 @@ const posix = if (Environment.isPosix) struct { .stack_size = 512 * 1024, }, signalInspectorThread, .{}) catch |err| { log("thread spawn failed: {s}", .{@errorName(err)}); + if (semaphore) |sem| sem.deinit(); + semaphore = null; return false; };