[PATCH 08/11] Cygwin: testsuite: Busy-wait in cancel3 and cancel5

Jon Turney jon.turney@dronecode.org.uk
Thu Jul 13 11:43:55 GMT 2023


On 13/07/2023 12:39, Jon Turney wrote:
> These tests async thread cancellation of a thread that doesn't have any
> cancellation points.
> 
> Unfortunately, since 450f557f the async cancellation silently fails when
> the thread is inside the kernel function Sleep(), so it just exits
> normally after 10 seconds. (See the commentary in pthread::cancel() in
> thread.cc, where it checks if the target thread is inside the kernel,
> and silently converts the cancellation into a deferred one)
> 
> Work around this by busy-waiting rather than Sleep()ing for 10 seconds.
> 
> This is still somewhat fragile: the async cancel could still fail, if it
> happens to occur while we're inside the kernel function that time()
> calls.
> 
> v2:
> Do nothing more efficiently
> ---
>   winsup/testsuite/winsup.api/pthread/cancel3.c | 24 ++++++++++++++-----
>   winsup/testsuite/winsup.api/pthread/cancel5.c | 24 ++++++++++++++-----
>   2 files changed, 36 insertions(+), 12 deletions(-)
> 

This still seems a bit flaky, for the reasons identified. Perhaps 
there's a better way of doing a pause without a cancellation point or 
entering the kernel? Or a better way to test that async cancellation 
actually works?



More information about the Cygwin-patches mailing list