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
try...finally adds strange lines to stacktraces #12584
Comments
And by line 5 i of course mean line 4 :) |
Thanks for the report. This is an artifact of the way we implement try-finally without a catch (or without a generic catch). We compile the program as if it were written: void main() { However, we further compile finally by translating it away (!), so we compile this new program as if it were written: void main() { That is: we have introduced two new hidden rethrows and two new hidden catch clauses. We use the same source code position for both of them, which is the position of the original "finally". I think the easiest fix is to mark the handlers for the two introduced catches as 'hidden' and not include them in the stack trace in the same way that we don't include hidden functions in the stack trace. I'll try to get to that next week unless someone else on the team wants to steal this. cc @iposva-google. |
We have discussed a completely revamped exception handling mechanism, which will likely make fixing this unnecessary. I am keeping this open though so that we can verify that it will be fixed as a "side-effect". Removed the owner. |
cc @sgmitrovic. |
This program also has a messed-up stack. import 'dart:typed_data'; class C { main() { $ sdk/bin/dart ~/play1/bug6V9.dart NoSuchMethodError : method not found: '*' |
The issue in comment #5 is different as there are no finally blocks involved. That report looks more like a simpler reproduction of issue #9. |
Both have n frames duplicates, in #5 n=3, for #1 n=1. This really should be fixed. Any progress? |
This seems to be fixed as the example is not reproducible anymore. Unhandled exception: Added Fixed label. |
Consider the following:
void main() {
try {
throw "error";
} finally {
}
}
Here the VM adds two extra lines to the stacktrace:
Unhandled exception:
error
0 main (file:///usr/local/google/home/ajohnsen/src/dart/dart/dev/simple_io.dart:3:5)
1 main (file:///usr/local/google/home/ajohnsen/src/dart/dart/dev/simple_io.dart:4:5)
2 main (file:///usr/local/google/home/ajohnsen/src/dart/dart/dev/simple_io.dart:4:5)
Note how line 5 is the line containing the '} finally {'. I would not expect the stacktrace to contain those lines at all.
(same goes for try..catch, but that will only add 1 line).
The text was updated successfully, but these errors were encountered: