Skip to content

Commit

Permalink
re-enable profiling stack switch test (JuliaLang#55553)
Browse files Browse the repository at this point in the history
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 JuliaLang#43124
  • Loading branch information
vtjnash authored and udesou committed Aug 28, 2024
1 parent 18b99d1 commit e537fe2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
8 changes: 6 additions & 2 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,17 @@ 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));
*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
memcpy_stack_a16((uint64_t*)_x, (uint64_t*)_y, nb); // destroys all but the current stackframe

#if defined(_OS_WINDOWS_)
Expand Down Expand Up @@ -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();
Expand Down
23 changes: 8 additions & 15 deletions test/threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit e537fe2

Please sign in to comment.