druntime icon indicating copy to clipboard operation
druntime copied to clipboard

WIP: Allow disabling exception trace info via --DRT-traceContext=off

Open kinke opened this issue 8 years ago • 2 comments

This should be more or less what @rainers suggested here. Seems to work after a single quick test. Should probably be upstreamed.

kinke avatar Jan 15 '17 16:01 kinke

Yeah, that's what I meant. The name of the option doesn't really describe its purpose, though. exceptionsCaptureCallStack would be clearer but a little verbose ;-)

On second thought: as there are little dependencies on this module, putting the initialization into a shared constructor executes it in arbitrary order with other shared constructors. So if there is an exception in an earlier constructor, the option still has its default. A user supplied shared constructor that sets the traceHandler would have the same effect.

I think it would behave more consistent with an explicit eh_init call from within rt_init. Instead of an additional boolean, Runtime.setTraceHandler could be used aswell.

BTW: Some time in the past I even hacked around the execution of the initializer in core.sys.windows.stackstrace because loading dbghelp.dll added considerable startup overhead. See https://github.com/dlang/visuald/blob/master/c2d/cpp2d_main.d#L830 (not sure if this still works, though).

rainers avatar Jan 16 '17 07:01 rainers

The name of the option doesn't really describe its purpose, though.

To be defined (upstream then), incl. value string (off). ;)

as there are little dependencies on this module, putting the initialization into a shared constructor executes it in arbitrary order with other shared constructors. So if there is an exception in an earlier constructor, the option still has its default. I think it would behave more consistent with an explicit eh_init call from within rt_init.

I looked into rt_init() first, then wasn't sure when it was safe to use rt.config, and finally decided that I don't really care about unwanted stack traces attached to exceptions thrown at startup before checking the DRT option and thus went for the simplest approach.

Instead of an additional boolean, Runtime.setTraceHandler could be used aswell.

Absolutely, I was also thinking about something like this (checking in _d_traceContext()), as it's simpler when supporting a multitude of platforms with different EH implementions.

I'll keep this PR here for the time being just so that we don't forget about this potential performance booster.

kinke avatar Jan 20 '17 18:01 kinke