druntime icon indicating copy to clipboard operation
druntime copied to clipboard

fix Issue 22774 - TraceInfo is gathered only once when throwing a Thr…

Open mkykadir opened this issue 3 years ago • 7 comments

…owable

Update info during every throw

mkykadir avatar Feb 15 '22 05:02 mkykadir

Thanks for your pull request and interest in making D better, @mkykadir! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
22774 minor TraceInfo is gathered only once when throwing a Throwable

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + druntime#3742"

dlang-bot avatar Feb 15 '22 05:02 dlang-bot

I think the fix for this should be in user code to set t.info = null if you want a new trace using the same throwable object.

thewilsonator avatar Feb 15 '22 07:02 thewilsonator

I think the fix for this should be in user code [...]

Why would one want this behavior ?

Geod24 avatar Feb 15 '22 07:02 Geod24

Unless the red in the CI is unrelated, then this break a whole lot of stuff.

thewilsonator avatar Feb 15 '22 11:02 thewilsonator

Unless the red in the CI is unrelated, then this break a whole lot of stuff.

Investigating this but generally time-out during fail-compilation tests (randomly); for example stuck at ... fail_compilation/test16116.d -verrors=0 -m64 -fPIC ()

mkykadir avatar Feb 19 '22 10:02 mkykadir

OK, one of the causes that I could find is this, this changeset conflicts with it. Exceptional cases when GC cannot be trusted (i.e. memory exceptions) are single instanced; and TraceInfo should not be constructed; this changeset causes that.

mkykadir avatar Feb 21 '22 07:02 mkykadir

I think the fix for this should be in user code [...]

Why would one want this behavior ?

In C#, there's a difference between throw; (a rethrow with the same context) and throw e; (new context): https://stackoverflow.com/questions/730250/is-there-a-difference-between-throw-and-throw-ex

In D:

try { foo(); }
catch (Exception e) { logException(e); throw e; } // keep the existing TraceInfo!

kinke avatar Feb 26 '22 13:02 kinke