Skip to content

Commit 3e7d5c4

Browse files
carstenbauerclaude
andcommitted
Copy masks in setaffinities to avoid mutating user data
ThreadPinningCore.setaffinity(mask) extends the mask in-place via append! when mask length < uv_cpumask_size(). This caused setaffinities to mutate the caller's mask objects, leading to test failures when comparing the mutated masks (now extended to uv_cpumask_size) against fresh getaffinity() results (truncated to cpuidlimit/Sys.CPU_THREADS). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e0c3364 commit 3e7d5c4

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/pinning.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ function setaffinities(masks; threadpool::Symbol = :default)
311311
throw(ArgumentError("Number of masks ($(length(masks))) must match the number of " *
312312
"threads ($(length(tids))) in the `$(threadpool)` threadpool."))
313313
for (i, threadid) in pairs(tids)
314-
setaffinity(masks[i]; threadid)
314+
setaffinity(copy(masks[i]); threadid)
315315
end
316316
return
317317
end

0 commit comments

Comments
 (0)