Skip to content

Commit b0caab1

Browse files
vtjnashKristofferC
authored andcommitted
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
1 parent 32341af commit b0caab1

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/task.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,14 +223,17 @@ JL_NO_ASAN static void NOINLINE JL_NORETURN restore_stack(jl_ucontext_t *t, jl_p
223223
}
224224
void *_y = t->stkbuf;
225225
assert(_x != NULL && _y != NULL);
226+
#if defined(_OS_WINDOWS_) // this platform does not implement CFI_NORETURN correctly or at all in libunwind (or equivalent) which requires a workaround
226227
#if defined(_CPU_X86_) || defined(_CPU_X86_64_)
227228
void *volatile *return_address = (void *volatile *)__builtin_frame_address(0) + 1;
228229
assert(*return_address == __builtin_return_address(0));
229230
*return_address = NULL;
230231
#else
231232
#pragma message("warning: CFI_NORETURN not implemented for this platform, so profiling of copy_stacks may segfault in this build")
232233
#endif
234+
#else
233235
CFI_NORETURN
236+
#endif
234237
memcpy_stack_a16((uint64_t*)_x, (uint64_t*)_y, nb); // destroys all but the current stackframe
235238

236239
#if defined(_OS_WINDOWS_)
@@ -287,14 +290,15 @@ JL_NO_ASAN static void NOINLINE restore_stack3(jl_ucontext_t *t, jl_ptls_t ptls,
287290
restore_stack3(t, ptls, p); // pass p to ensure the compiler can't tailcall this or avoid the alloca
288291
}
289292
#endif
293+
#if defined(_OS_WINDOWS_) // this platform does not implement CFI_NORETURN correctly or at all in libunwind (or equivalent) which requires a workaround
290294
#if defined(_CPU_X86_) || defined(_CPU_X86_64_)
291295
void *volatile *return_address = (void *volatile *)__builtin_frame_address(0) + 1;
292296
assert(*return_address == __builtin_return_address(0));
293297
*return_address = NULL;
294-
#else
295-
#pragma message("warning: CFI_NORETURN not implemented for this platform, so profiling of copy_stacks may segfault in this build")
296298
#endif
299+
#else
297300
CFI_NORETURN
301+
#endif
298302
tsan_switch_to_ctx(t);
299303
jl_start_fiber_set(t); // (doesn't return)
300304
abort();

test/threads.jl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,18 +288,16 @@ close(proc.in)
288288
proc = run(cmd; wait = false)
289289
done = Threads.Atomic{Bool}(false)
290290
timeout = false
291-
timer = Timer(100) do _
291+
timer = Timer(200) do _
292292
timeout = true
293-
for sig in [Base.SIGTERM, Base.SIGHUP, Base.SIGKILL]
294-
for _ in 1:1000
293+
for sig in (Base.SIGQUIT, Base.SIGKILL)
294+
for _ in 1:3
295295
kill(proc, sig)
296+
sleep(1)
296297
if done[]
297-
if sig != Base.SIGTERM
298-
@warn "Terminating `$script` required signal $sig"
299-
end
298+
@warn "Terminating `$script` required signal $sig"
300299
return
301300
end
302-
sleep(0.001)
303301
end
304302
end
305303
end
@@ -309,16 +307,11 @@ close(proc.in)
309307
done[] = true
310308
close(timer)
311309
end
312-
if ( !success(proc) ) || ( timeout )
310+
if !success(proc) || timeout
313311
@error "A \"spawn and wait lots of tasks\" test failed" n proc.exitcode proc.termsignal success(proc) timeout
314312
end
315-
if Sys.iswindows() || Sys.isapple()
316-
# Known failure: https://github.com/JuliaLang/julia/issues/43124
317-
@test_skip success(proc)
318-
else
319-
@test success(proc)
320-
@test !timeout
321-
end
313+
@test success(proc)
314+
@test !timeout
322315
end
323316
end
324317

0 commit comments

Comments
 (0)