Repository navigation
fix(concurrency): report a root coroutine error once, not twice - #22
Merged
zombocoder merged 2 commits intoOct 27, 2026
Merged
zombocoder merged 2 commits into
zombocoder merged 2 commits into
Conversation
When Main.main() fails, the scheduler printed "Error in coroutine #0: ..." and Interpreter::execute() then re-threw the captured root exception, which main.cpp reports again as "Error: ...". Every runtime error in a program's main method therefore appeared twice on stderr. The root coroutine's exception is already captured in root_exception_ and re-thrown by its only caller, so only print errors from non-root coroutines in the scheduler. Behavior and exit codes are otherwise unchanged. Signed-off-by: svaiml <88979468+svaiml@users.noreply.github.com>
…ll printed root_exception_not_printed_by_scheduler: a failing root coroutine is captured in root_exception_ and not also printed by the scheduler (fails without the previous commit: stderr contains "Error in coroutine #0"). non_root_exception_still_printed: errors from non-root coroutines are still reported by the scheduler. Signed-off-by: sashml <sashml@users.noreply.github.com>
zombocoder
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
Main.main()fails at runtime, the error is printed twice:The scheduler prints every failed coroutine, including the root one. But the root coroutine's
exception is also captured in
root_exception_, re-thrown byInterpreter::execute()and reported bymain.cpp.Fix
In
Scheduler::run(), print only errors from non-root coroutines. The root coroutine's exception isstill captured and re-thrown by its only caller, so the program still exits
1with a singleError: ...line. Errors in spawned coroutines are reported exactly as before.Tests
Two cases added to
tests/test_root_exception.cpp:root_exception_not_printed_by_scheduler: the root error is captured and not printed by thescheduler. It fails without the fix (stderr contains
Error in coroutine #0).non_root_exception_still_printed: a spawned coroutine's error is still printed.Verification
mainwith this branch merged: build OK,o2l_tests528/528 passing.main()prints oneError: ...line and exits1; a clean one exits0. The same program on currentmainprints both lines shown above.clang-format(repository.clang-format) reports nothing on the changed lines.