-
Notifications
You must be signed in to change notification settings - Fork 1.7k
VM crash when inspecting a parameter in VSCode debugger #59653
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
Comments
Summary: VS Code debugger causes VM crash when inspecting a local variable's value during debugging. The crash occurs in |
//cc @derekxu16 |
A smaller repro, that I arrived at by reducing the given repro, is to hover over
I haven't found the root cause of the crash yet, but it's possible to avoid the crash by removing the extension type, i.e. changing the code to:
So, I should be able to figure out the root cause by looking into what the VM is doing differently when the extension type is present versus when it isn't. |
I’ve now created two repros that are even smaller. Example 1 includes an extension type and crashes: import 'dart:developer' show debugger;
abstract interface class SharedTypeStructure {}
extension type SharedTypeSchemaView<TypeStructure extends SharedTypeStructure>(
TypeStructure _typeStructure
)
implements Object {}
class C extends SharedTypeStructure {}
class ClassWithTypeAnalyzer<TypeStructure extends SharedTypeStructure> {
SharedTypeSchemaView<TypeStructure> dispatchExpression(
SharedTypeSchemaView<TypeStructure> schema,
) {
return schema;
}
void analyzeExpression(SharedTypeSchemaView<TypeStructure> schema) {
debugger(); // Evaluate 'dispatchExpression(schema)';
}
}
void main() {
final classWithTypeAnalyzer = ClassWithTypeAnalyzer<C>();
classWithTypeAnalyzer.analyzeExpression(SharedTypeSchemaView(C()));
} Example 2 does not include an extension type and does not crash: import 'dart:developer' show debugger;
abstract interface class SharedTypeStructure {}
class C extends SharedTypeStructure {}
class ClassWithTypeAnalyzer<TypeStructure> {
int dispatchExpression(TypeStructure schema) {
return 123;
}
void analyzeExpression(TypeStructure schema) {
debugger(); // Evaluate 'dispatchExpression(schema as TypeStructure)';
}
}
void main() {
final classWithTypeAnalyzer = ClassWithTypeAnalyzer<C>();
classWithTypeAnalyzer.analyzeExpression(C());
} The crash in example 1 happens when the VM tries to finalize the signature of the expression evaluation function. The sdk/runtime/vm/class_finalizer.cc Line 388 in 751fe13
The problem is that the @johnniwinther or @jensjoha, is it possible that references to the Here is the human-readable dump of the expression evaluation function kernel from example 1:
Here is the human-readable dump of the expression evaluation function kernel from example 2:
|
I might have changed the examples a little bit, but nevertheless. What the normal compile creates for a similar thing:
What the expression compiler creates:
I'd say that looks fair. Then the whole thing is wrapped in a component though:
Notice how we now reference the type parameter on the Let's compare that to a version without an extension type. From the normal compiler:
What the expression compiler creates:
And wrapped in a component.
Notice how we don't reference any type parameter at all (this is probably because we use the runtime type --- which we don't on extension types because they don't 'exist' at runtime --- but still). In the VM source I found this:
So - at least in some places in the VM - when we see, say, class From other debug-printing I noticed this:
Notice how it seemingly knows X0, but also doesn't know X0? And from debug-printing the "normal load":
Lots of other prints etc I got to this: https://dart-review.googlesource.com/c/sdk/+/405381 It at least fixes this reproduction. |
Thanks, @jensjoha!
I think setting |
Maybe we should eagerly set However, substituting |
(Note: I've been seeing crashes like this for at least a month; this is the first time I've figured out a repro)
Build the latest Dart SDK as of abb17bc. Then check out this code.
Using Visual Studio Code, with the SDK set to the SDK that was just built:
pkg/_fe_analyzer_shared/lib/src/type_inference/null_shorting.dart
and place a breakpoint on line 17.pkg/analyzer/test/src/dart/resolution/extension_method_test.dart
. Click on the "Debug" button that appears above line 12.pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart
to line 583.node
on line 568.Expected behavior: the value of the local variable
node
is shown in a pop-up.Observed behavior: the VM crashes with the following stacktrace:
Stacktrace
The text was updated successfully, but these errors were encountered: