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

Compiler crash with optional Finalizable parameter #49402

Closed
blaugold opened this issue Jul 5, 2022 · 4 comments
Closed

Compiler crash with optional Finalizable parameter #49402

blaugold opened this issue Jul 5, 2022 · 4 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi

Comments

@blaugold
Copy link
Contributor

blaugold commented Jul 5, 2022

The following code causes a compiler crash when compiled with dart compile exe:

class A implements Finalizable {}

void b([A? a]) {}

void main() {
  b();
}

Here is the stacktrace generated when building a Flutter app that contains the above code:

../../third_party/dart/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc: 5839: error: Unexpected tag 106
version=2.18.0-256.0.dev (dev) (Tue Jul 5 05:08:29 2022 -0700) on "macos_x64"
pid=13001, thread=259, isolate_group=isolate(0x7fb64b01c800), isolate=(nil)(0x0)
isolate_instructions=0, vm_instructions=0
  pc 0x0000000102b90885 fp 0x0000000309dde550 dart::Profiler::DumpStackTrace(void*)+0x85
  pc 0x00000001029d5404 fp 0x0000000309dde630 dart::Assert::Fail(char const*, ...) const+0x84
  pc 0x0000000102e32244 fp 0x0000000309dde680 dart::kernel::StreamingFlowGraphBuilder::BuildReachabilityFence()+0x1e4
  pc 0x0000000102e29687 fp 0x0000000309dde710 dart::kernel::StreamingFlowGraphBuilder::BuildStaticInvocation(dart::TokenPosition*)+0x397
  pc 0x0000000102e23294 fp 0x0000000309dde760 dart::kernel::StreamingFlowGraphBuilder::BuildStatement(dart::TokenPosition*)+0xc4
  pc 0x0000000102e2c28a fp 0x0000000309dde7c0 dart::kernel::StreamingFlowGraphBuilder::BuildBlock(dart::TokenPosition*)+0x9a
  pc 0x0000000102e24667 fp 0x0000000309dde860 dart::kernel::StreamingFlowGraphBuilder::BuildFunctionBody(dart::Function const&, dart::LocalVariable*, bool)+0xf7
  pc 0x0000000102e24da9 fp 0x0000000309ddea10 dart::kernel::StreamingFlowGraphBuilder::BuildGraphOfFunction(bool)+0x329
  pc 0x0000000102e25304 fp 0x0000000309ddeb00 dart::kernel::StreamingFlowGraphBuilder::BuildGraph()+0x164
  pc 0x0000000102e37a93 fp 0x0000000309ddedd0 dart::kernel::FlowGraphBuilder::BuildGraph()+0x73
  pc 0x0000000102db3934 fp 0x0000000309ddf300 dart::CallSiteInliner::TryInliningImpl(dart::Function const&, dart::Array const&, dart::InlinedCallData*, bool)+0xb04
  pc 0x0000000102da8c66 fp 0x0000000309ddf3a0 dart::CallSiteInliner::TryInlining(dart::Function const&, dart::Array const&, dart::InlinedCallData*, bool)+0xf6
  pc 0x0000000102db72fb fp 0x0000000309ddf4a0 dart::CallSiteInliner::InlineStaticCalls()+0x5cb
  pc 0x0000000102dae515 fp 0x0000000309ddf5c0 dart::CallSiteInliner::InlineCalls()+0x255
  pc 0x0000000102dae15b fp 0x0000000309ddf6c0 dart::FlowGraphInliner::Inline()+0x1db
  pc 0x0000000102e06cb2 fp 0x0000000309ddf730 dart::CompilerPass_Inlining::DoBody(dart::CompilerPassState*) const+0x52
  pc 0x0000000102e0593f fp 0x0000000309ddf800 dart::CompilerPass::Run(dart::CompilerPassState*) const+0x1af
  pc 0x0000000102e05e19 fp 0x0000000309ddf830 dart::CompilerPass::RunPipeline(dart::CompilerPass::PipelineMode, dart::CompilerPassState*)+0xa9
  pc 0x0000000102cfeb0f fp 0x0000000309ddfef0 dart::PrecompileParsedFunctionHelper::Compile(dart::CompilationPipeline*)+0x4ef
  pc 0x0000000102cff602 fp 0x0000000309de0580 dart::PrecompileFunctionHelper(dart::Precompiler*, dart::CompilationPipeline*, dart::Function const&, bool)+0x322
  pc 0x0000000102cfa6c4 fp 0x0000000309de0680 dart::Precompiler::CompileFunction(dart::Precompiler*, dart::Thread*, dart::Zone*, dart::Function const&)+0x174
  pc 0x0000000102cf7d30 fp 0x0000000309de0720 dart::Precompiler::ProcessFunction(dart::Function const&)+0xf0
  pc 0x0000000102cf2564 fp 0x0000000309de0780 dart::Precompiler::Iterate()+0xa4
  pc 0x0000000102cecd00 fp 0x0000000309de0ed0 dart::Precompiler::DoCompileAll()+0x12e0
  pc 0x0000000102ceb99b fp 0x0000000309de1330 dart::Precompiler::CompileAll()+0xbb
  pc 0x0000000102ebab8f fp 0x0000000309de14a0 Dart_Precompile+0x17f
  pc 0x00000001029ccf38 fp 0x0000000309de1630 dart::bin::main(int, char**)+0x9a8
  pc 0x000000020336b51e fp 0x0000000309de1740 Unknown symbol
-- End of DumpStackTrace
=== Crash occured when compiling package:finalizable_issue_repro/main.dart_::_main in AOT mode in Inlining pass
package:finalizable_issue_repro/main.dart:1
*** BEGIN CFG
Inlining
==== package:finalizable_issue_repro/main.dart_::_main (RegularFunction)
package:finalizable_issue_repro/main.dart:1
B0[graph]:0 {
      v0 <- Constant(#null) T{Null?}

}
B1[function entry]:2
    CheckStackOverflow:8(stack=0, loop=0)
    DebugStepCheck:10()
    StaticCall:12( b<0> )
    StaticCall:14( runApp<0> )
    DebugStepCheck:16()
    Return:18(v0)
*** END CFG
Flutter 3.1.0-0.0.pre.1505 • channel master • https://github.com/flutter/flutter.git
Framework • revision 39a38b7882 (5 hours ago) • 2022-07-05 12:34:08 -0400
Engine • revision 8197dec7e2
Tools • Dart 2.18.0 (build 2.18.0-256.0.dev) • DevTools 2.15.0
@blaugold blaugold changed the title Compile crash with optional Finalizable parameter Compiler crash with optional Finalizable parameter Jul 5, 2022
@lrhn lrhn added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. library-ffi labels Jul 6, 2022
@mraleph
Copy link
Member

mraleph commented Jul 6, 2022

/cc @dcharkes

@dcharkes
Copy link
Contributor

dcharkes commented Jul 6, 2022

Thanks for reporting @blaugold!
I can reproduce this on master.
I have a fix ready at https://dart-review.googlesource.com/c/sdk/+/250744.

@dcharkes
Copy link
Contributor

dcharkes commented Jul 7, 2022

@blaugold are you in need of a cherry pick to stable for this? Or are you always running on master?

@blaugold
Copy link
Contributor Author

blaugold commented Jul 7, 2022

Thanks for the quick fix. It would be great to have the fix in stable, since this issue was found in a package that is published to pub.dev.

copybara-service bot pushed a commit that referenced this issue Jul 12, 2022
This is a patch release that fixes:

- Improve code completion for Flutter (issue [#49054][]).
- Fix crash on ARM (issue [#106510][]).
- Fix compiler crash with Finalizable parameters (issue [#49402][]).

[#49054]: #49054
[#106510]: flutter/flutter#106510
[#49402]: #49402

Change-Id: I9a814603d9793b75b764fd0f384e89017e773c50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251109
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
copybara-service bot pushed a commit that referenced this issue Jul 12, 2022
The kernel builder relied on only seeing expressions emitted by the
finalizable transform (variable get and this) as arguments to the fence.

However, other transforms can run later. In this case the expression
was turned into a constant.

This CL changes the implementation to accept any expression rather than
accepting a subset of expressions.

TEST=tests/ffi/regress_49402_test.dart

Closes: #49402
Change-Id: I1a962a5b7a38099eb5c3bbf5a5a8145b16727d97
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250744
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
copybara-service bot pushed a commit that referenced this issue Jul 12, 2022
This is a patch release that fixes:

- Improve code completion for Flutter (issue [#49054][]).
- Fix crash on ARM (issue [#106510][]).
- Fix compiler crash with Finalizable parameters (issue [#49402][]).

[#49054]: #49054
[#106510]: flutter/flutter#106510
[#49402]: #49402

Change-Id: I9a814603d9793b75b764fd0f384e89017e773c50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251109
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
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. library-ffi
Projects
None yet
Development

No branches or pull requests

4 participants