-
Notifications
You must be signed in to change notification settings - Fork 29
Conversation
@@ -377,14 +383,14 @@ void msvc_eh_terminate() nothrow | |||
mov RBX, 0xFFFFFF; | |||
and RDX, RBX; | |||
cmp RDX, 0xC48348; // add ESP,nn (debug UCRT libs) | |||
je L_addESP_found; | |||
je L_addESP_found; |
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.
Thanks for the PR, I'll test it over the weekend. All changes starting with this one seem to be different line endings only. Could you please fix that (for the whole file)?
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.
I just edit the file on the github (using the chrome browser), I really do not know why the line endings changed?
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.
The mixture of line endings is probably my fault. Even with the editorconfig plugin VS seems to produce these quite often. I suppose the chrome editor has converted everything to unix-style (which is ok).
exceptionStack.push(throwable); | ||
|
||
if (throwable.info is null && cast(byte*)throwable !is typeid(throwable).init.ptr) | ||
throwable.info = _d_traceContext(); |
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.
Even though this is the behaviour used on other platfroms or in dmd, I don't think it should be encouraged: it can make exceptions unusable slow, even if only used in rare cases. The trace should only be created with the catch statement that actually wants to print it. That's quite a bit more difficult to implement, though...
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.
Interesting info, thanks. I'd rather have Windows streamlined with the other platforms though (and create an enhancement issue wrt. performance and your idea how to improve on it), don't you agree?
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.
Maybe need a option to let user choose not to generate the stack traceback, like this:
throw Exception("", stackTrace=false)
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.
When constructing the exception, the user generally doesn't have any idea about where it's going to unwind to and whether there are catch handlers interested in the trace. throw -> _d_throw_exception()
could check for registered handlers at runtime though, but it would also require compiler support to register the handlers while in a try
scope.
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.
don't you agree?
I'm ok with streamlining for now. Disabling the stack trace generation could be done through a -DRT-option for exception heavy applications.
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.
your idea how to improve on it
I lost a branch of druntime in a SSD crash that had that for dmd's Win32 exception handling: The type of the d_run_main catch handler had a specific type that was detected during the search phase of the exception unwinding when the stack of the throw was still available. I guess this is not so easily integrated into the MS C++ runtime without being able to modify it...
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.
I lost a branch of druntime in a SSD crash
Sorry to hear that :/ - you got me slightly worried about my SSD and my reluctance to backups now. ;)
I'm ok with streamlining for now.
Perfect.
Disabling the stack trace generation could be done through a -DRT-option for exception heavy applications.
You mean as CMake option to be forwarded as -d-version=...
when compiling your own speedy-Gonzalez druntime? Or more fine-grained by extending _d_throw_exception()
by a compile-time bool depending on LDC switch, to allow compiling specific modules with no stack traces attached to thrown exceptions?
Edit: In that case, we could also introduce a pragma/UDA controlling the stack trace generation.
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.
--DRT-
refers to process command line arguments implicitly picked up by druntime.
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 I see, thanks, never heard of this before. Disabling it per process sounds very reasonable.
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.
--DRT options can also be embedded in the executable or picked up from the environment. See https://dlang.org/spec/garbage.html#gc_config
Thanks, works fine with The stack trace is excellent on Win64 now:
On Ubuntu 16.04 it's pretty bad though:
|
@xiren7: The stack trace is empty on Win32, even with
|
The When with But when on win32 with The probability when the stack trace is empty on win32 is about 10%(why?), but can not reproduce with ldc(win32)// druntime/src/core/runtime.d
static enum FIRSTFRAME = 2;
console output(no stack trace):
debugger output(no stack trace):
console output(has stack trace):
debugger output(has stack trace):
dmd(win32)
console output:
debugger output:
ldc(win32, link-debuglib, FIRSTFRAME = 2)
console output:
ldc(win32, link-debuglib, FIRSTFRAME = 1)
The missed top frame:
ldc(win32, link-debuglib, FIRSTFRAME = 0)
ldc(win64, link-debuglib, FIRSTFRAME = 1)
ldc(win64, link-debuglib, FIRSTFRAME = 3)
|
Confirmed, |
Rather than hardcoding FIRSTFRAME, can't we do something like on DWARF instead where _d_throw_exception is detected by name? I don't think the small performance cost would be significant compared to the rest of EH/backtracing. |
Implemented by 6d4cf2f. |
Tested in win32 and win64 with '-g' option.
(I did not touch the assembly code but the code modified automaticly.)
Update:
The added code is simply copied from _d_throw_exception(druntime/src/ldc/eh/libunwind.d)
Update2:
win32 must with '-g -disable-fp-elim' option
Update3:
druntime/src/core/runtime.d