Restore output capture of R tasks correctly#1065
Conversation
Summary [ 162.183s] 925 tests run: 924 passed, 1 failed, 0 skipped
FAIL [ 11.481s] (702/925) ark::kernel-captured-output
test_pending_idle_task_does_not_swallow_stdout
stdout ───
running 1 test
test test_pending_idle_task_does_not_swallow_stdout ... FAILED
a8b1a37 to
a29838f
Compare
|
This is causing the debugonce failure that tripped up @juliasilge's PR in posit-dev/positron@52dc638 I could only inconsistently reproduce the failure manually, but very consistently when running the test. In the harness, I saw these messages: Notice the last "INFO [Captured idle output]" message, confirming the namespace population task is swallowing user output. I've confirmed that with the fix in this PR, the test now passes as expected. The output capture seen in this log is from Why do we only see the E2E test fail only with dev Ark? I'm not entirely sure, but it might have to do with the environment refresh implemented in https://github.com/posit-dev/ark/pull/1052/changes, which triggers a new non-idle task that might shift the event loop just in the right way that the execute request gets picked up while a pending idle task's capture is active. In any case, the test failure is very consistently reproducible without the fix, and I can't reproduce with it. Now onto the risks created by this bug. The risk mostly depends on whether the tasks yield or not. If they don't yield, they will complete in one go. If they do, they will become pending while capturing output and if an execute request is picked up at that time the output is swallowed. Idle tasks are involved in:
So I'd say the risk is limited overal. (3) and (4) are fine since the tasks don't yield. For (1), there's a brief window of time after calling So I think I'm comfortable with letting the bug slip in the release, although I'd also be happy to get a fix in. |
|
We chatted over the weekend and I agree it's OK for the release to go out as is, without this fix. Thanks for working on this, @lionel-! 🙌 |
| } | ||
|
|
||
| #[macro_export] | ||
| macro_rules! soft_assert { |
There was a problem hiding this comment.
why not debug_assert!, like debug_panic!?
they both have the same implication:
- panic, but only die during debug
- assert, but only die during debug
There was a problem hiding this comment.
That's the name I initially picked, but it conflicts with a macro in the standard library. I thought it's fine to have stdext::debug_assert! as a disambiguator but then ran into complications due to scoping of macro exports at top-level that I don't fully understand.
Previously we were only restoring the output capture on Drop, when the idle task was completely finished. If the task yielded with
.awaitand went pending, giving control back to R, the output capture would remain in place! This PR fixes that by restoring the output capture at yield points.Fixes some test failures I observed in the quiet debugger branch.
And we can now test the R task infra!