Closed berteauxjb closed 1 week ago
Thanks for the PR. I approved the CI for this PR. The tests crash on Windows (Exception: SegFault
). Any idea what is going on there?
Thanks for the PR. I approved the CI for this PR. The tests crash on Windows (
Exception: SegFault
). Any idea what is going on there?
I was able to reproduce on a Windows machine :smile: It turns out that the wp->mutex
is only initialized if wp->nthreads > 1
. In the test there is only 1 thread, and workerpool_add_task
was accessing a non-initialized mutex. I shielded the usage of the mutex with if (wp->nthreads > 1)
like it's done in other places in the file.
Thanks a lot!
I encountered random segfaults while using this library and tried to figure out what was happening. I isolated the segfault to the function
worker_thread()
ofworkerpool.c
. Long story short, there is no predicate that preventsworker_thread()
from running if it is woken up spuriously and a task has already been added. Since there is no mutex used inworkerpool_add_task()
, it is possible for the zarraywp->tasks
to be reallocated, rendering the volatile pointertask
inworker_thread()
invalid and causing a segfault.This PR addresses this issue by adding a predicate and shielding calls that access
wp
behind a mutex. I also saw issue #70 and agree that the initialization of the worker threads might lead to race conditions, so I addressed that too.