Skip to content

[vm] NNBD - Instance Type: class 'Never' is not canonical #40249

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

Closed
dcharkes opened this issue Jan 21, 2020 · 8 comments
Closed

[vm] NNBD - Instance Type: class 'Never' is not canonical #40249

dcharkes opened this issue Jan 21, 2020 · 8 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. NNBD Issues related to NNBD Release vm-nnbd-unfork-sdk Label for all issues that need to be done before the nnbd sdk can be unforked

Comments

@dcharkes
Copy link
Contributor

dcharkes commented Jan 21, 2020

Instance `Type: class 'Never'` is not canonical!
../../runtime/vm/heap/verifier.cc: 100: error: expected: is_canonical

Using Never as a type argument in dart:ffi breaks the NNBD debug build.

Is this on your NNBD-work radar @liamappelbe @a-siva?

If not, I'm happy to look at it myself.

How to repro, change <Null> to <Never> in:

final Pointer<Null> nullptr = Pointer.fromAddress(0);

I expect us to need something like the following in object.cc:

   cls = object_store->never_class();
    type = Type::New(cls, Object::null_type_arguments(),
                     TokenPosition::kNoSource, Nullability::kNullable);
    type.SetIsFinalized();
    type ^= type.Canonicalize();
    object_store->set_never_type(type);

Full log:

FAILED: gen/kernel-service.dart.snapshot 
python ../../build/gn_run_binary.py compiled_action dart --deterministic --packages=/b/s/w/ir/cache/builder/sdk/.packages --snapshot=gen/kernel-service.dart.snapshot --snapshot-depfile=/b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/kernel-service.dart.snapshot.d --enable-experiment=non-nullable --snapshot-kind=app-jit /b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/utils/kernel-service/kernel-service_snapshot.dart.dill --train file:///b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/dart2js.dart
Command failed: ./dart --deterministic --packages=/b/s/w/ir/cache/builder/sdk/.packages --snapshot=gen/kernel-service.dart.snapshot --snapshot-depfile=/b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/kernel-service.dart.snapshot.d --enable-experiment=non-nullable --snapshot-kind=app-jit /b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/utils/kernel-service/kernel-service_snapshot.dart.dill --train file:///b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/dart2js.dart
output: ../../pkg/compiler/lib/src/dart2js.dart: Warning: Interpreting this as package URI, 'package:compiler/src/dart2js.dart'.
Instance `Type: class 'Never'` is not canonical!
../../runtime/vm/heap/verifier.cc: 100: error: expected: is_canonical
version=2.8.0-edge.f910a7575f3cfcd3641620baf6440b0fd4c674c5 (Tue Jan 21 06:22:51 2020 +0000) on "linux_x64"
thread=22868, isolate=main(0x560082825800)
  pc 0x000056007fbecf5c fp 0x00007ffc24adc250 dart::Profiler::DumpStackTrace(void*)
  pc 0x000056007f81e582 fp 0x00007ffc24adc330 dart::Assert::Fail(char const*, ...)
  pc 0x000056007febb1c9 fp 0x00007ffc24adc360 ./dart+0x1fc01c9
  pc 0x000056007feaa1a0 fp 0x00007ffc24adc3c0 dart::HeapPage::VisitObjects(dart::ObjectVisitor*) const
  pc 0x000056007fead951 fp 0x00007ffc24adc430 dart::PageSpace::VisitObjects(dart::ObjectVisitor*) const
  pc 0x000056007fac1898 fp 0x00007ffc24adc4a0 dart::Isolate::ValidateConstants()
  pc 0x000056008012cac1 fp 0x00007ffc24adc700 Dart_CreateAppJITSnapshotAsBlobs
  pc 0x000056007f802653 fp 0x00007ffc24adc740 dart::bin::Snapshot::GenerateAppJIT(char const*)
  pc 0x000056007f804b94 fp 0x00007ffc24adc7e0 dart::bin::RunMainIsolate(char const*, dart::bin::CommandLineOptions*)
  pc 0x000056007f8059ec fp 0x00007ffc24adc8f0 dart::bin::main(int, char**)
  pc 0x000056007f806659 fp 0x00007ffc24adc900 ./dart+0x190b659
-- End of DumpStackTrace

ninja: build stopped: subcommand failed.
ninja -C out/DebugX64NNBD -j200 -l64 create_sdk done.

https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8890659953347632368/+/steps/build_dart/0/stdout

Blocks: #40233

@dcharkes dcharkes added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. NNBD Issues related to NNBD Release vm-nnbd-unfork-sdk Label for all issues that need to be done before the nnbd sdk can be unforked labels Jan 21, 2020
@dcharkes
Copy link
Contributor Author

dcharkes commented Jan 22, 2020

Fixing the first error:

RawType* Type::NewNonParameterizedType(const Class& type_class) {
  ASSERT(type_class.NumTypeArguments() == 0);
  if (type_class.IsNullClass()) {
    return Type::NullType();
  }
  // Add this.
  if (type_class.IsNeverClass()) {
    return Type::NeverType();
  }

Edit: Scratch that, that will just push the null value around:

ninja: Entering directory `out/DebugX64NNBD'
[16/125] ACTION //runtime/bin:generate_snapshot_bin(//build/toolchain/linux:clang_x64)
FAILED: gen/runtime/bin/vm_snapshot_data.bin gen/runtime/bin/vm_snapshot_instructions.bin gen/runtime/bin/isolate_snapshot_data.bin gen/runtime/bin/isolate_snapshot_instructions.bin 
python ../../build/gn_run_binary.py compiled_action gen_snapshot --enable-experiment=non-nullable --deterministic --snapshot_kind=core --vm_snapshot_data=gen/runtime/bin/vm_snapshot_data.bin --vm_snapshot_instructions=gen/runtime/bin/vm_snapshot_instructions.bin --isolate_snapshot_data=gen/runtime/bin/isolate_snapshot_data.bin --isolate_snapshot_instructions=gen/runtime/bin/isolate_snapshot_instructions.bin /usr/local/google/home/dacoharkes/dart-sdk/sdk/out/DebugX64NNBD/vm_platform_strong_stripped.dill
Command failed: ./gen_snapshot --enable-experiment=non-nullable --deterministic --snapshot_kind=core --vm_snapshot_data=gen/runtime/bin/vm_snapshot_data.bin --vm_snapshot_instructions=gen/runtime/bin/vm_snapshot_instructions.bin --isolate_snapshot_data=gen/runtime/bin/isolate_snapshot_data.bin --isolate_snapshot_instructions=gen/runtime/bin/isolate_snapshot_instructions.bin /usr/local/google/home/dacoharkes/dart-sdk/sdk/out/DebugX64NNBD/vm_platform_strong_stripped.dill
output: ../../runtime/vm/object.h: 7438: error: expected: raw() != null()
version=2.8.0-edge.b1d21349466862c4fad314e58cbb17abf861b2a6 (Wed Jan 22 17:35:39 2020 +0100) on "linux_x64"
thread=27901, isolate=vm-isolate(0x5614b1e7c000)
  pc 0x00005614b056a5cc fp 0x00007ffc0d8c5220 dart::Profiler::DumpStackTrace(void*)
  pc 0x00005614b02dcc02 fp 0x00007ffc0d8c5300 dart::Assert::Fail(char const*, ...)
  pc 0x00005614b0516406 fp 0x00007ffc0d8c5320 ./gen_snapshot+0x84e406
  pc 0x00005614b0631c4c fp 0x00007ffc0d8c5360 dart::TypeTestingStubGenerator::DefaultCodeForType(dart::AbstractType const&, bool)
  pc 0x00005614b0499c49 fp 0x00007ffc0d8c5380 dart::Object::FinishInit(dart::Isolate*)
  pc 0x00005614b03da198 fp 0x00007ffc0d8c5560 dart::Dart::Init(unsigned char const*, unsigned char const*, _Dart_Isolate* (*)(char const*, char const*, char const*, char const*, Dart_IsolateFlags*, void*, char**), bool (*)(void**, char**), void (*)(void*, void*), void (*)(void*, void*), void (*)(void*), void (*)(), void* (*)(char const*, bool), void (*)(unsigned char**, long*, void*), void (*)(void const*, long, void*), void (*)(void*), bool (*)(unsigned char*, long), _Dart_Handle* (*)(), bool, Dart_CodeObserver*)
  pc 0x00005614b0aad839 fp 0x00007ffc0d8c55c0 Dart_Initialize
  pc 0x00005614b02b1fa7 fp 0x00007ffc0d8c5750 dart::bin::main(int, char**)
-- End of DumpStackTrace

@dcharkes dcharkes assigned dcharkes and unassigned liamappelbe and a-siva Jan 22, 2020
@alexmarkov
Copy link
Contributor

/cc @crelier

@dcharkes
Copy link
Contributor Author

dcharkes commented Feb 4, 2020

I haven't check yet if any of the fixes landed last week fixed this.

I made a CL for the repro: https://dart-review.googlesource.com/c/sdk/+/134320.

edit: still failing: https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8889367976788673424/+/steps/build_dart/0/stdout

@crelier
Copy link
Contributor

crelier commented Feb 4, 2020

Thanks for the repro. I'll have a look today.

@crelier crelier assigned crelier and unassigned dcharkes Feb 4, 2020
@dcharkes
Copy link
Contributor Author

dcharkes commented Feb 5, 2020

Now it fails a bit later in the build step with runtime/vm/object.cc: 19182: error: expected: type.IsCanonical().

[2401/2482] ACTION //utils/kernel-service:kernel-service_snapshot(//build/toolchain/linux:clang_x64)
FAILED: gen/kernel-service.dart.snapshot 
python ../../build/gn_run_binary.py compiled_action dart --deterministic --packages=/b/s/w/ir/cache/builder/sdk/.packages --snapshot=gen/kernel-service.dart.snapshot --snapshot-depfile=/b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/kernel-service.dart.snapshot.d --snapshot-kind=app-jit /b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/utils/kernel-service/kernel-service_snapshot.dart.dill --train file:///b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/dart2js.dart
Command failed: ./dart --deterministic --packages=/b/s/w/ir/cache/builder/sdk/.packages --snapshot=gen/kernel-service.dart.snapshot --snapshot-depfile=/b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/kernel-service.dart.snapshot.d --snapshot-kind=app-jit /b/s/w/ir/cache/builder/sdk/out/DebugX64NNBD/gen/utils/kernel-service/kernel-service_snapshot.dart.dill --train file:///b/s/w/ir/cache/builder/sdk/pkg/compiler/lib/src/dart2js.dart
output: ../../pkg/compiler/lib/src/dart2js.dart: Warning: Interpreting this as package URI, 'package:compiler/src/dart2js.dart'.
../../runtime/vm/object.cc: 19182: error: expected: type.IsCanonical()
version=2.8.0-edge.8408232522765e29fb6c42e53b6d122456c5c35e (Wed Feb 5 08:46:07 2020 +0000) on "linux_x64"
thread=32011, isolate=main(0x5623914c7800)
isolate_instructions=56238e91de80, vm_instructions=56238e91de80
  pc 0x000056238ecf0bbc fp 0x00007ffccee64560 dart::Profiler::DumpStackTrace(void*)
  pc 0x000056238e91b722 fp 0x00007ffccee64640 dart::Assert::Fail(char const*, ...)
  pc 0x000056238ec9f25f fp 0x00007ffccee646d0 dart::Type::CheckIsCanonical(dart::Thread*) const
  pc 0x000056238efc52ba fp 0x00007ffccee64700 dart::VerifyCanonicalVisitor::VisitObject(dart::RawObject*)
  pc 0x000056238efb4280 fp 0x00007ffccee64760 dart::HeapPage::VisitObjects(dart::ObjectVisitor*) const
  pc 0x000056238efb7ad1 fp 0x00007ffccee647d0 dart::PageSpace::VisitObjects(dart::ObjectVisitor*) const
  pc 0x000056238ebc0858 fp 0x00007ffccee64840 dart::Isolate::ValidateConstants()
  pc 0x000056238f236b71 fp 0x00007ffccee64aa0 Dart_CreateAppJITSnapshotAsBlobs
  pc 0x000056238e8ff6f3 fp 0x00007ffccee64ae0 dart::bin::Snapshot::GenerateAppJIT(char const*)
  pc 0x000056238e901d24 fp 0x00007ffccee64b80 dart::bin::RunMainIsolate(char const*, dart::bin::CommandLineOptions*)
  pc 0x000056238e902b7c fp 0x00007ffccee64c90 dart::bin::main(int, char**)
  pc 0x000056238e9037f9 fp 0x00007ffccee64ca0 ./dart+0x18e97f9
-- End of DumpStackTrace

https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8889307427402633328/+/steps/build_dart/0/stdout
https://dart-review.googlesource.com/c/sdk/+/134320

@dcharkes dcharkes reopened this Feb 5, 2020
@crelier
Copy link
Contributor

crelier commented Feb 5, 2020

Arrgh, I patched your repro in the wrong workspace and did not test this properly. Sorry. I'll get back to it...

@crelier
Copy link
Contributor

crelier commented Feb 7, 2020

Dart-bot mistakenly closed this issue. Reopening.
The real fix is under review.

@crelier crelier reopened this Feb 7, 2020
@dcharkes
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. NNBD Issues related to NNBD Release vm-nnbd-unfork-sdk Label for all issues that need to be done before the nnbd sdk can be unforked
Projects
None yet
Development

No branches or pull requests

5 participants