-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
insert backtrace printing into user-facing JL_CATCH #38201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! :)
Yeah on windows the output get's mangled.
|
True, I guess it's not good to intermix writes to JL_STDERR with STDERR_FILENO |
Since `jlbacktrace` uses `STDERR_FILENO` directly we have to be a bit careful to avoid mangled errors (particularily on Windows), so we use `STDERR_FILENO` directly, when also using `jlbacktrace`.
a068497
to
3c33910
Compare
@@ -492,6 +492,9 @@ static int exec_program(char *program) | |||
jl_load(jl_main_module, program); | |||
} | |||
JL_CATCH { | |||
// TODO: It is possible for this output | |||
// to be mangled due to `jlbacktrace` | |||
// printing directly to STDERR_FILENO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to resolve this as you've done elsewhere then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't immediately clear to me how to do so. The code mixes JL_STDERR
and jl_stderr_objs
and I presume it does so for a reason. I am not sure if it is gurantueed that hose two streams will be the same.
Some git archeology shows that this is code from the ancient times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes I see. So it seems that errs
could certainly be pointing to some other stream if redirect_stderr
was called. I think the fix here, in principle, is to have some shim to call display_error()
rather than printing the current exception and backtrace separately. If display_error
doesn't exist or fails, then the fallback path of shown_err == 0
would be taken.
insert backtrace printing into user-facing JL_CATCH
In #38134 (comment) I found it impossible to tell
which finalizer is to blame. With this a stacktrace is being printed:
In this example the finalizer is
#9 at ./REPL[4]:11