Skip to content
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

language: guarantee that rethrow preserves stack trace identity #18394

Closed
kasperl opened this issue Apr 23, 2014 · 13 comments
Closed

language: guarantee that rethrow preserves stack trace identity #18394

kasperl opened this issue Apr 23, 2014 · 13 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).

Comments

@kasperl
Copy link

kasperl commented Apr 23, 2014

See issue #15171. I think it makes sense to put this in the language spec as it is a core property of the rethrow semantics.

   var e0, e1, s0, s1;
   try {
     try {
       throw 42;
     } catch (e, s) {
       s0 = s;
       e0 = e;
       rethrow;
     }
   } catch (e, s) {
     e1 = e;
     s1 = s;
   }
   assert(identical(e0, e1));
   assert(identical(s0, s1));

@kasperl
Copy link
Author

kasperl commented Apr 23, 2014

Marked this as blocking #15171.

@gbracha
Copy link
Contributor

gbracha commented Apr 23, 2014

If you feel it's important, we can certainly do that. I find it an odd guarantee to make.


Set owner to @gbracha.
Added Accepted label.

@lrhn
Copy link
Member

lrhn commented Apr 23, 2014

I'm also not convinced that the stack traces need to be identical.
Can you explain why you think it is important?

@sethladd
Copy link
Contributor

cc @nex3.
cc @efortuna.

@nex3
Copy link
Member

nex3 commented Apr 23, 2014

For a practical use case, this property is critical for implementing stack chain capturing as is currently done in the stack_trace package. It uses an expando on stack traces to track the prior traces in the chain, but this only works if the same stack trace has consistent identity over time. Stack chains are an important tool for debugging asynchronous code, but currently they don't work under dart2js because it doesn't support this property.

@kasperl
Copy link
Author

kasperl commented Apr 25, 2014

Not sure I understand the argument against guaranteeing this? We have to specify that rethrow preserves the original stack trace somehow (that's 100% essential) and the simplest way of specifying what preserving means is to say that it preserves identity. Also, it's by far the simplest way of implementing it.

@kasperl
Copy link
Author

kasperl commented May 8, 2014

Removed this from the 1.4 milestone.
Added this to the 1.5 milestone.

@kasperl
Copy link
Author

kasperl commented Jun 4, 2014

Removed this from the 1.5 milestone.
Added this to the 1.6 milestone.

@kasperl
Copy link
Author

kasperl commented Jul 10, 2014

Removed this from the 1.6 milestone.
Added Oldschool-Milestone-1.6 label.

@kasperl
Copy link
Author

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-1.6 label.

@sigmundch
Copy link
Member

Whats the current status on this?

The spec 2nd edition says about rethrow (17.10):

Let f be the immediately enclosing function, and let on T catch (p1, p2)
be the immediately enclosing catch clause (17.11).
A rethrow statement always appears inside a catch clause, and any catch
clause is semantically equivalent to some catch clause of the form on T catch
(p1, p2). So we can assume that the rethrow is enclosed in a catch clause of
that form.

The current exception (16.9) is set to p1, the current return value (17.12)
becomes undefined, and the active stack trace (17.11) is set to p2.

This last sentence reads to me as if the stack trace objects must be identical.

@gbracha
Copy link
Contributor

gbracha commented Jun 2, 2015

We did introduce this wording into the second edition (it was not there in the first edition). I forget the history, but as worded, it does imply that rethrow preserves the stack object.

@sigmundch
Copy link
Member

Great, thanks! I'm closing this issue as fixed and move forward with fixing the dart2js implementation.


Added Fixed label.

@kasperl kasperl added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Jun 2, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language).
Projects
None yet
Development

No branches or pull requests

7 participants