Add error dialog for critical errors on Windows#54836
Add error dialog for critical errors on Windows#54836topolarity merged 3 commits intoJuliaLang:masterfrom
Conversation
9f57800 to
37ce01c
Compare
7768244 to
ca4254f
Compare
| event_source, EVENTLOG_ERROR_TYPE, /* category */ 0, /* event_id */ (DWORD)0xE0000000L, | ||
| /* user_sid */ NULL, /* n_strings */ 1, /* data_size */ 0, strings, /* data */ NULL | ||
| ); | ||
| MessageBoxW(NULL, /* message */ L"error: libjulia received a fatal signal.\n\n" |
There was a problem hiding this comment.
I know very little about Windows, so my apologies if these questions are dumb, but: 1. Is this call async, or does it block?
2. Is this really safe to call here? In particular,
3. I am slightly worried about situations I experienced in an entirely different context were broadly similar code could lead to hundreds of dialog boxes spamming a user (when code that launched a ton of subprocesses to process data had them all fail simultaneously -- e.g. because a network connection dropped).
Anyway, none of this is meant as argument against this PR (which to me, as a non-Windows user, seems quite useful). Feel free to ignore me :-)
There was a problem hiding this comment.
On 1: it blocks the thread.
There was a problem hiding this comment.
a151cf3 added a jl_options guard
It's disabled by default now, but will be enabled by PackageCompiler when exporting Julia-based libraries - hopefully that resolves some of the concern. These are "critical" errors, so in some sense they should never happen (although in practice aggressive Ctrl-C at the REPL makes them happen quite a bit, so it's good that we don't alert in that case)
|
Probably also needs to detect scenarios where no windows desktop is present? SSH, PowerShell remoting, running as a service etc. Somehow making the dialog box optional seems like a good idea to me. |
vtjnash
left a comment
There was a problem hiding this comment.
SGTM, I think this should work okay
|
Was this closed intentionally? |
377554f to
d4137f1
Compare
It was, but #54835 has since been re-opened I'll be re-visiting this soon since "Julia as a library" scenarios on Windows are becoming relevant soon |
This adds/changes a number of `fprint_*` variants to internal debug
functions:
- rename + new `ios_t *` argument:
- `jl_critical_error` -> `jl_fprint_critical_error`
- `jl_print_native_codeloc` -> `jl_fprint_native_codeloc`
- `jl_print_bt_entry_codeloc` -> `jl_fprint_bt_entry_codeloc`
- `jl_gc_debug_print_status` -> `jl_gc_debug_fprint_status`
- `jl_gc_debug_critical_error` -> `jl_gc_debug_fprint_critical_error`
- new `fprint_*` variants:
- `jl_safe_fprintf`
- `jl_safe_static_show`
- `jl_fprint_backtrace(t)`
Note that care needs to be taken w.r.t. what `ios_t *` value is passed
into these functions from within a signal handler on Unix. Memory
allocation is not async-signal-safe, so the ios_t needs to wrap a raw
`fd_t` handle.
Immediate motivation is #54836
802487c to
a151cf3
Compare
a151cf3 to
f558752
Compare
|
build failure looks related |
This can be very useful when your Julia-built library hits an unexpected exception and causes a GUI-based application to crash with no error message.
This is disabled by default, but it can be enabled by downstream applications (in particular, by JuliaC.jl / PackageCompiler) so Windows users with a Julia library in a pure GUI application will get a useful error message for a crash.
f558752 to
280cb72
Compare
Fixed. Do we have not have |
|
IIRC, Werror is currently only enabled for linux builders in buildkite, since nobody has thought to enable it for others |
It's actually only missing for Windows (should be enabled already for all Unices platforms) because nobody went through all the warnings issued when targeting that platform, which is what Cody has now been working on starting with #59634 |
This adds/changes a number of `fprint_*` variants to internal debug
functions:
- rename + new `ios_t *` argument:
- `jl_critical_error` -> `jl_fprint_critical_error`
- `jl_print_native_codeloc` -> `jl_fprint_native_codeloc`
- `jl_print_bt_entry_codeloc` -> `jl_fprint_bt_entry_codeloc`
- `jl_gc_debug_print_status` -> `jl_gc_debug_fprint_status`
- `jl_gc_debug_critical_error` -> `jl_gc_debug_fprint_critical_error`
- new `fprint_*` variants:
- `jl_safe_fprintf`
- `jl_safe_static_show`
- `jl_fprint_backtrace(t)`
Note that care needs to be taken w.r.t. what `ios_t *` value is passed
into these functions from within a signal handler on Unix. Memory
allocation is not async-signal-safe, so the ios_t needs to wrap a raw
`fd_t` handle.
Immediate motivation is JuliaLang#54836
This change adds a small dialog (disabled by default) for fatal errors on Windows with a corresponding entry in the `Application` log (in Event Viewer, enabled by default) This is intended primarily for users of PackageCompiler.jl, who might be using Julia in a GUI application. If a Julia-compiled library fails in a GUI application, users currently have no good way to know why/how their application crashed if, e.g., an exception was accidentally left unhandled in their Julia code. Depends on JuliaLang#54835
This change adds a small dialog for fatal errors on Windows:
with a corresponding entry in the

Applicationlog (in Event Viewer)This is intended primarily for users of PackageCompiler.jl, who might be using Julia in a GUI application.
If a Julia-compiled library fails in a GUI application, users currently have no good way to know why/how their application crashed if, e.g., an exception was accidentally left unhandled in their Julia code.
Depends on #54835
TODO: Should this be a
jl_optionsflag to determine whether to show the GUI? Should we log to the event log unconditionally? Is there any way that we can automatically detect whetherstderris connected to a terminal and user-visible?