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

Running an app in VSCode in debug mode with an assert statement: could not load source #35392

Closed
footurist opened this issue Dec 12, 2018 · 13 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@footurist
Copy link

I installed the dart-sdk via chocolatey. The latest version (2.1.0) is installed. The error does not happen when I run the app via command-line with the --enable-asserts flag.

void main() {
  assert(false);
}

// VSCode creates a temp file to replace the missing file which contains:
Could not load source 'dart:core/runtime/liberrors_patch.dart': <source not available>.

Why can't VSCode find this file?

@zoechi
Copy link
Contributor

zoechi commented Dec 13, 2018

@DanTup

@DanTup
Copy link
Collaborator

DanTup commented Dec 13, 2018

Why can't VSCode find this file?

The VM no longer providers source code for some internal libraries. I'm guessing this is one (@devoncarew?).

VS Code is supposed to walk up the stack to the first frame that has source code (so you'd be looking at the call to assert rather than it's implementation - why isn't available), however it's broken -> microsoft/vscode#64193. I think once that's fixed things should be much better (but it seems like it's not likely to be fixed in December; please do put a 👍 and/or comment if it's affecting you badly).

@zoechi
Copy link
Contributor

zoechi commented Dec 13, 2018

flutter/flutter#24912 is about a similar error.

@DanTup
Copy link
Collaborator

DanTup commented Dec 13, 2018

Although the error is the same, I think the question there is more about the failure that resulted in it breaking, than the fact it's not showing the source - I've added some notes on how to figure out what's wrong (and encouraging people to 👍 the VS Code issue, since it doesn't seem to be considered high priority).

@devoncarew
Copy link
Member

We're going to look at restoring source code for dart: source, but this might not happen for a few releases.

@DanTup
Copy link
Collaborator

DanTup commented Dec 13, 2018

I think that's both good and bad :-)

If we do nothing, and VS Code fix their bug, the user would end up looking at their call to assert. But if we put this source back, they'll end up looking at the implementation of assert which is likely much less useful (and they'll need to manually walk up the stack).

I wonder if VS Code would consider some flag that lets us control which frames should be auto-focused without it being the same "has source" (or let us control which frame to focus on explicitly when an exception occurs). That way we could put the user in a good place while still giving them the source to dig into.

Slightly related is: #29156 though I don't know if that's fixable without hiding the top stack frames (which probably isn't the best solution).

@kevmoo
Copy link
Member

kevmoo commented Dec 20, 2018

@devoncarew – would you triage? Is this an SDK issue? VM? analyzer?

@DanTup
Copy link
Collaborator

DanTup commented Jan 2, 2019

@devoncarew

We're going to look at restoring source code for dart: source, but this might not happen for a few releases.

@DanTup

I think that's both good and bad :-)

FWIW, this behaviour/change shouldn't impact VS Code negatively now. VS Code have fixed a bug and added a new feature that will let us focus the correct code when an exception occurs (even if it's not top of the stack).

So, I think restoring the sources would be a good change (especially as it's really confusing that you can Go-to-definition into them via the analyzer today, then when you Step Into with the debugger we say they're missing).

@vsmenon vsmenon added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jan 3, 2019
@vsmenon
Copy link
Member

vsmenon commented Jan 3, 2019

@devoncarew - triaging as analyzer for now. Please feel free to move. :-)

@DanTup
Copy link
Collaborator

DanTup commented Jan 3, 2019

I think this is a combination of two issues:

  1. A VS Code where it breaks at the top of the stack even if there's no source - this is fixed in VS Code vNext (Breaking on exception should jump to top frame that has source microsoft/vscode#64193)
  2. Source code for the framework isn't available via the VM so the user can't see the code that threw the error (even with 1 fixed, the user may try to navigate to a stack frame that is framework code). I think that's the same issue that @jensjoha has raised here Sources stripped in vm_platform_strong.dill #34832

In which case, probably we don't need this additional issue.

@devoncarew
Copy link
Member

I think this is safe to close given the upcoming VS Code fix.

We can track work to restore dart: sources in #34832 (I do think it's important to get that restored - I've hit the issue in different contexts several times since the dart: change).

@GanongLS
Copy link

This issues still pertaining even in dec 2020.

@DanTup
Copy link
Collaborator

DanTup commented Jan 6, 2021

@GanongLS I don't seem to be able to reproduce this using the code above. Could you file an issue at https://github.com/Dart-Code/Dart-Code with an exact code example and the exact SDK version you're using?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

7 participants