From 233f61bc2cfbb22d0edeb2594da27a20d2ce514e Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Mon, 19 Jan 2026 13:18:38 -0500 Subject: [PATCH] Initialize the mutexattr before use. (#3482) As observed by @kkebo, this was missing from the implementation. ### Motivation: Correct pthread API usage. ### Modifications: Initialize the pthread_mutexattr_t with pthread_mutexattr_init before passed to pthread_mutex_init. ### Result: Even though this lock API appears to be deprecated, we'll correct the usage anyway. The non-deprecated NIOLock class doesn't have this problem. --- Sources/NIOConcurrencyHelpers/lock.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/NIOConcurrencyHelpers/lock.swift b/Sources/NIOConcurrencyHelpers/lock.swift index 4a83de3ad..4a62f7570 100644 --- a/Sources/NIOConcurrencyHelpers/lock.swift +++ b/Sources/NIOConcurrencyHelpers/lock.swift @@ -57,7 +57,9 @@ public final class Lock { InitializeSRWLock(self.mutex) #elseif os(OpenBSD) var attr = pthread_mutexattr_t(bitPattern: 0) - let err = pthread_mutex_init(self.mutex, &attr) + var err = pthread_mutexattr_init(&attr) + precondition(err == 0, "\(#function) failed in pthread_mutexattr_init with error \(err)") + err = pthread_mutex_init(self.mutex, &attr) precondition(err == 0, "\(#function) failed in pthread_mutex with error \(err)") #elseif (compiler(<6.1) && !os(WASI)) || (compiler(>=6.1) && _runtime(_multithreaded)) var attr = pthread_mutexattr_t()