Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-enable profiling stack switch test #55553

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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