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

Add try/catch around handle_message() to catch errors during logging (#57004) #204

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Jan 17, 2025

PR Description

Backport fix to prevent failed transactions from logging bugs.
Fixes RAI-33715.

Checklist

Requirements for merging:

…JuliaLang#57004)

Fixes JuliaLang#56889.

Before this PR, an exception thrown while constructing the objects to
log (the `msg`) would be caught and logged. However, an exception thrown
while _printing_ the msg to an IO would _not_ be caught, and can abort
the program. This breaks the promise that enabling verbose debug logging
shouldn't introduce new crashes.

After this PR, an exception thrown during handle_message is caught and
logged, just like an exception during `msg` construction:

```julia
julia> struct Foo end

julia> Base.show(::IO, ::Foo) = error("oh no")

julia> begin
           # Unexpectedly, the execption thrown while printing `Foo()` escapes
           @info Foo()
           # So we never reach this line! :'(
           println("~~~~~ ALL DONE ~~~~~~~~")
       end
┌ Error: Exception while generating log record in module Main at REPL[10]:3
│   exception =
│    oh no
│    Stacktrace:
│      [1] error(s::String)
│        @ Base ./error.jl:44
│      [2] show(::IOBuffer, ::Foo)
│        @ Main ./REPL[9]:1
...
│     [30] repl_main
│        @ ./client.jl:593 [inlined]
│     [31] _start()
│        @ Base ./client.jl:568
└ @ Main REPL[10]:3
~~~~~ ALL DONE ~~~~~~~~
```

This PR respects the change made in
JuliaLang#36600 to keep the codegen as
small as possible, by putting the new try/catch into a no-inlined
function, so that we don't have to introduce a new try/catch in the
macro-generated code body.

---------

Co-authored-by: Jameson Nash <[email protected]>
@github-actions github-actions bot added port-to-v1.10 This change should apply to Julia v1.10 builds port-to-master This change should apply to all future Julia builds labels Jan 17, 2025
@NHDaly NHDaly removed the port-to-v1.10 This change should apply to Julia v1.10 builds label Jan 17, 2025
@NHDaly
Copy link
Member Author

NHDaly commented Jan 17, 2025

All tests have passed on the RAICode pr.

@NHDaly NHDaly requested a review from a team January 17, 2025 19:18
Copy link

@Sacha0 Sacha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nathan! :)

@NHDaly NHDaly merged commit d0efc46 into v1.10.2+RAI Jan 17, 2025
9 checks passed
@NHDaly NHDaly deleted the nhd-backport-57004 branch January 17, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port-to-master This change should apply to all future Julia builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants