compiler: preserve task starts during trimming#61499
Conversation
Teach trim reachability to treat task creation as a deferred callback edge so task entry thunks survive trimming, and add verifier and trimming coverage for concrete and unresolved task starts. Co-authored-by: OpenAI Codex <codex@openai.com> (cherry picked from commit 4833746c443d83829ce134ac9279b349fd9cc38d)
Switch the SecretBuffer GC-shred warning away from structured logging so the finalizer task does not pull the logging stack into trim verification. Co-authored-by: OpenAI Codex <codex@openai.com>
| end | ||
|
|
||
| function final_shred!(s::SecretBuffer) | ||
| !isshredded(s) && @async @warn("a SecretBuffer was `shred!`ed by the GC; use `shred!` manually after use to minimize exposure.") |
There was a problem hiding this comment.
These drive by changes aren't great. This should either go in a different PR or to the juliac.jl list of pirate fixes
There was a problem hiding this comment.
Yeah, this just caused the tests to fail w/ the Task fixes because it was now flagging the @warn as non-trim-compile-able. So you're saying we should do that fix first in a separate PR and then rebase this off that?
There was a problem hiding this comment.
Yes, this should be a separate PR
|
The former is about the handling of finalizers (and Tasks were discussed) and the latter is a more principled approach of teaching inference about Tasks and their properties, it's a much larger change, but I think the change in |
|
Yeah, if #59221 will get in, that certainly seems like the best way to fix (+ all the other benefits!). |
|
Bump; I would really love to have Tasks trim-compileable, whether its with this approach or another. Would this be a good triage discussion topic? |
|
triage is probably the wrong audience, but agreed that we should figure out how to do this |
|
I'm a bit reluctant to merge dedicated BTW Task support (and multi-threading in general) is on my radar for |
Teach trim reachability to treat task creation as a deferred callback edge so task entry thunks survive trimming, and add verifier and trimming coverage for concrete and unresolved task starts.
An example trim-compile test where the proposed changes here "fix" rooting the Task code is: https://github.com/JuliaServices/Reseau.jl/blob/main/test/tls_trim_safe.jl#L43 (i.e. we can remove the entrypoint rooting and the Task code still survives trimming).
I'm working on some additional higher-level HTTP trim tests in this PR, but need to massage unrelated verifier errors first (getting close). I've confirmed in some local, lower-level server/client tests that these changes also fix things.
DISLCAIMER: I'm not familiar with this code at all and heavily relied on codex AI/LLM to propose the fix, so apologies if this is way off or not the direction we want to go. At least from the little I do understand, it seems reasonable to key off of jl_new_task, but I'm not sure if there are other entrypoints/Task-related intrinsics we'd still be missing.