mirror of
https://github.com/oven-sh/bun
synced 2026-02-16 05:42:43 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user