From 688811d73fb24f5f91a6d01f445207042b991a79 Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 27 Aug 2024 14:15:14 -0400 Subject: [PATCH] re-enable profiling stack switch test (#55553) Removes the warning on platforms where CFI_NORETURN appears likely to be sufficient alone for this to work (from observation in gdb/lldb) and re-enables the test on all platforms so we can see if more work here is needed at all (e.g. similar annotations in jl_setjmp/jl_longjmp). Refs #43124 --- src/task.c | 8 ++++++-- test/threads.jl | 23 ++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/task.c b/src/task.c index a88f3b55fc419..86acac23a186a 100644 --- a/src/task.c +++ b/src/task.c @@ -223,6 +223,7 @@ JL_NO_ASAN static void NOINLINE JL_NORETURN restore_stack(jl_ucontext_t *t, jl_p } void *_y = t->stkbuf; assert(_x != NULL && _y != NULL); +#if defined(_OS_WINDOWS_) // this platform does not implement CFI_NORETURN correctly or at all in libunwind (or equivalent) which requires a workaround #if defined(_CPU_X86_) || defined(_CPU_X86_64_) void *volatile *return_address = (void *volatile *)__builtin_frame_address(0) + 1; assert(*return_address == __builtin_return_address(0)); @@ -230,7 +231,9 @@ JL_NO_ASAN static void NOINLINE JL_NORETURN restore_stack(jl_ucontext_t *t, jl_p #else #pragma message("warning: CFI_NORETURN not implemented for this platform, so profiling of copy_stacks may segfault in this build") #endif +#else CFI_NORETURN +#endif memcpy_stack_a16((uint64_t*)_x, (uint64_t*)_y, nb); // destroys all but the current stackframe #if defined(_OS_WINDOWS_) @@ -287,14 +290,15 @@ JL_NO_ASAN static void NOINLINE restore_stack3(jl_ucontext_t *t, jl_ptls_t ptls, restore_stack3(t, ptls, p); // pass p to ensure the compiler can't tailcall this or avoid the alloca } #endif +#if defined(_OS_WINDOWS_) // this platform does not implement CFI_NORETURN correctly or at all in libunwind (or equivalent) which requires a workaround #if defined(_CPU_X86_) || defined(_CPU_X86_64_) void *volatile *return_address = (void *volatile *)__builtin_frame_address(0) + 1; assert(*return_address == __builtin_return_address(0)); *return_address = NULL; -#else -#pragma message("warning: CFI_NORETURN not implemented for this platform, so profiling of copy_stacks may segfault in this build") #endif +#else CFI_NORETURN +#endif tsan_switch_to_ctx(t); jl_start_fiber_set(t); // (doesn't return) abort(); diff --git a/test/threads.jl b/test/threads.jl index 7b4558091022b..2832f2a0e972c 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -288,18 +288,16 @@ close(proc.in) proc = run(cmd; wait = false) done = Threads.Atomic{Bool}(false) timeout = false - timer = Timer(100) do _ + timer = Timer(200) do _ timeout = true - for sig in [Base.SIGTERM, Base.SIGHUP, Base.SIGKILL] - for _ in 1:1000 + for sig in (Base.SIGQUIT, Base.SIGKILL) + for _ in 1:3 kill(proc, sig) + sleep(1) if done[] - if sig != Base.SIGTERM - @warn "Terminating `$script` required signal $sig" - end + @warn "Terminating `$script` required signal $sig" return end - sleep(0.001) end end end @@ -309,16 +307,11 @@ close(proc.in) done[] = true close(timer) end - if ( !success(proc) ) || ( timeout ) + if !success(proc) || timeout @error "A \"spawn and wait lots of tasks\" test failed" n proc.exitcode proc.termsignal success(proc) timeout end - if Sys.iswindows() || Sys.isapple() - # Known failure: https://github.com/JuliaLang/julia/issues/43124 - @test_skip success(proc) - else - @test success(proc) - @test !timeout - end + @test success(proc) + @test !timeout end end