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

Races between background compiler and unopt switchable calls implementation #37595

Closed
Hixie opened this issue Jul 22, 2019 · 20 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@Hixie
Copy link
Contributor

Hixie commented Jul 22, 2019

Compling dev\bots\test.dart on Windows from this commit:
flutter/flutter@63ffbfb

...caused this crash:

C:\Windows\Temp\flutter sdk>call dart --enable-asserts dev\bots\test.dart 
Crash when compiling file:///C:/Users/ContainerAdministrator/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/base_request.dart,
at character offset 3931:
file:///C:/Users/ContainerAdministrator/AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/src/base_request.dart:116:40: Internal problem: Unsupported operation: 'this.plainNameForRead'.
      var response = await client.send(this);
                                       ^
#0      internalProblem (package:front_end/src/fasta/problems.dart:45:3)
#1      unsupported (package:front_end/src/fasta/problems.dart:72:10)
#2      ThisAccessGenerator.plainNameForRead (package:front_end/src/fasta/kernel/kernel_expression_generator_impl.dart:30:12)
#3      KernelGenerator.makeInvalidRead (package:front_end/src/fasta/kernel/kernel_expression_generator.dart:240:13)
#4      KernelGenerator._makeRead (package:front_end/src/fasta/kernel/kernel_expression_generator.dart:267:23)
#5      KernelGenerator._makeSimpleRead (package:front_end/src/fasta/kernel/kernel_expression_generator.dart:259:35)
#6      KernelGenerator.buildSimpleRead (package:front_end/src/fasta/kernel/kernel_expression_generator.dart:137:20)
#7      BodyBuilder.toValue (package:front_end/src/fasta/kernel/body_builder.dart:336:19)
#8      BodyBuilder.endArguments (package:front_end/src/fasta/kernel/body_builder.dart:1277:31)
#9      Parser.parseArgumentsRest (package:front_end/src/fasta/parser/parser.dart:5030:14)
#10     Parser.parseArguments (package:front_end/src/fasta/parser/parser.dart:4976:12)
#11     Parser.parseArgumentsOpt (package:front_end/src/fasta/parser/parser.dart:4957:14)
#12     Parser.parseSend (package:front_end/src/fasta/parser/parser.dart:4936:13)
#13     Parser.parseSendOrFunctionLiteral (package:front_end/src/fasta/parser/parser.dart:4672:12)
#14     Parser.parsePrimary (package:front_end/src/fasta/parser/parser.dart:4243:14)
#15     Parser.parsePrecedenceExpression (package:front_end/src/fasta/parser/parser.dart:4014:21)
#16     Parser.parseAwaitExpression (package:front_end/src/fasta/parser/parser.dart:5749:13)
#17     Parser.parseUnaryExpression (package:front_end/src/fasta/parser/parser.dart:4135:14)
#18     Parser.parsePrecedenceExpression (package:front_end/src/fasta/parser/parser.dart:3970:13)
#19     Parser.parseExpression (package:front_end/src/fasta/parser/parser.dart:3942:13)
#20     Parser.parseVariableInitializerOpt (package:front_end/src/fasta/parser/parser.dart:2511:15)
#21     Parser.parseOptionallyInitializedIdentifier (package:front_end/src/fasta/parser/parser.dart:5378:13)
#22     Parser.parseVariablesDeclarationRest (package:front_end/src/fasta/parser/parser.dart:5359:13)
#23     Parser.parseExpressionStatementOrDeclarationAfterModifiers (package:front_end/src/fasta/parser/parser.dart:5352:15)
#24     Parser.parseStatementX (package:front_end/src/fasta/parser/parser.dart:3736:16)
#25     Parser.parseStatement (package:front_end/src/fasta/parser/parser.dart:3714:20)
#26     Parser.parseBlock (package:front_end/src/fasta/parser/parser.dart:5684:15)
#27     Parser.parseTryStatement (package:front_end/src/fasta/parser/parser.dart:5827:26)
#28     Parser.parseStatementX (package:front_end/src/fasta/parser/parser.dart:3760:14)
#29     Parser.parseStatement (package:front_end/src/fasta/parser/parser.dart:3714:20)
#30     Parser.parseFunctionBody (package:front_end/src/fasta/parser/parser.dart:3619:15)
#31     DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:804:14)
#32     DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:592:5)
#33     Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3271:14)
#34     Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:3128:15)
#35     Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2904:15)
#36     Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1795:13)
#37     Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1755:14)
#38     Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:570:14)
#39     Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:486:14)
#40     Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:348:15)
#41     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:281:14)
<asynchronous suspension>
#42     Loader.buildBodies (package:front_end/src/fasta/loader.dart:186:15)
<asynchronous suspension>
#43     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:296:20)
<asynchronous suspension>
#44     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#45     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:294:12)
<asynchronous suspension>
#46     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:152:38)
<asynchronous suspension>
#47     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#48     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:59:10)
<asynchronous suspension>
#49     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:41:18)
<asynchronous suspension>
#50     CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>
#51     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#52     new Future.sync (dart:async/future.dart:224:31)
#53     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#54     _rootRun (dart:async/zone.dart:1124:13)
#55     _CustomZone.run (dart:async/zone.dart:1021:19)
#56     _runZoned (dart:async/zone.dart:1516:10)
#57     runZoned (dart:async/zone.dart:1463:12)
#58     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#59     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#60     generateKernel (package:front_end/src/kernel_generator_impl.dart:40:32)
<asynchronous suspension>
#61     kernelForComponent (package:front_end/src/api_prototype/kernel_generator.dart:91:17)
<asynchronous suspension>
#62     SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/k/src/third_party/dart/pkg/vm/bin/kernel_service.dart:316:11)
<asynchronous suspension>
#63     Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/k/src/third_party/dart/pkg/vm/bin/kernel_service.dart:150:31)
<asynchronous suspension>
#64     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#65     _rootRun (dart:async/zone.dart:1120:38)
#66     _CustomZone.run (dart:async/zone.dart:1021:19)
#67     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#68     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#69     _rootRun (dart:async/zone.dart:1124:13)
#70     _CustomZone.run (dart:async/zone.dart:1021:19)
#71     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#72     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#73     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
#74     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#75     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)


#0      DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:812:7)
#1      DietListener.endMethod (package:front_end/src/fasta/source/diet_listener.dart:592:5)
#2      Parser.parseMethod (package:front_end/src/fasta/parser/parser.dart:3271:14)
#3      Parser.parseClassOrMixinMemberImpl (package:front_end/src/fasta/parser/parser.dart:3128:15)
#4      Parser.parseClassOrMixinBody (package:front_end/src/fasta/parser/parser.dart:2904:15)
#5      Parser.parseClass (package:front_end/src/fasta/parser/parser.dart:1795:13)
#6      Parser.parseClassOrNamedMixinApplication (package:front_end/src/fasta/parser/parser.dart:1755:14)
#7      Parser.parseTopLevelKeywordDeclaration (package:front_end/src/fasta/parser/parser.dart:570:14)
#8      Parser.parseTopLevelDeclarationImpl (package:front_end/src/fasta/parser/parser.dart:486:14)
#9      Parser.parseUnit (package:front_end/src/fasta/parser/parser.dart:348:15)
#10     SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:281:14)
<asynchronous suspension>
#11     Loader.buildBodies (package:front_end/src/fasta/loader.dart:186:15)
<asynchronous suspension>
#12     KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:296:20)
<asynchronous suspension>
#13     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#14     KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:294:12)
<asynchronous suspension>
#15     generateKernelInternal.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:152:38)
<asynchronous suspension>
#16     withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
<asynchronous suspension>
#17     generateKernelInternal (package:front_end/src/kernel_generator_impl.dart:59:10)
<asynchronous suspension>
#18     generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:41:18)
<asynchronous suspension>
#19     CompilerContext.runWithOptions.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:134:20)
<asynchronous suspension>
#20     CompilerContext.runInContext.<anonymous closure>.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:46)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CompilerContext.runInContext.<anonymous closure> (package:front_end/src/fasta/compiler_context.dart:122:19)
#23     _rootRun (dart:async/zone.dart:1124:13)
#24     _CustomZone.run (dart:async/zone.dart:1021:19)
#25     _runZoned (dart:async/zone.dart:1516:10)
#26     runZoned (dart:async/zone.dart:1463:12)
#27     CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:121:12)
#28     CompilerContext.runWithOptions (package:front_end/src/fasta/compiler_context.dart:132:10)
#29     generateKernel (package:front_end/src/kernel_generator_impl.dart:40:32)
<asynchronous suspension>
#30     kernelForComponent (package:front_end/src/api_prototype/kernel_generator.dart:91:17)
<asynchronous suspension>
#31     SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/k/src/third_party/dart/pkg/vm/bin/kernel_service.dart:316:11)
<asynchronous suspension>
#32     Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/k/src/third_party/dart/pkg/vm/bin/kernel_service.dart:150:31)
<asynchronous suspension>
#33     new Future.<anonymous closure> (dart:async/future.dart:176:37)
#34     _rootRun (dart:async/zone.dart:1120:38)
#35     _CustomZone.run (dart:async/zone.dart:1021:19)
#36     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#37     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#38     _rootRun (dart:async/zone.dart:1124:13)
#39     _CustomZone.run (dart:async/zone.dart:1021:19)
#40     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:947:23)
#41     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:21:15)
#42     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:382:19)
#43     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:416:5)
#44     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)


C:\Windows\Temp\flutter sdk>if 252 NEQ 0 exit /b 252 

Exit status: 252
@Hixie
Copy link
Contributor Author

Hixie commented Jul 22, 2019

@vsmenon
Copy link
Member

vsmenon commented Jul 22, 2019

fyi - @danrubel - looks like a fasta issue?

@devoncarew
Copy link
Member

@devoncarew devoncarew added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Jul 22, 2019
@johnniwinther
Copy link
Member

This looks very weird. The call
#6 KernelGenerator.buildSimpleRead (package:front_end/src/fasta/kernel/kernel_expression_generator.dart:137:20)
ends up in
#2 ThisAccessGenerator.plainNameForRead (package:front_end/src/fasta/kernel/kernel_expression_generator_impl.dart:30:12)
which means the object is a ThisAccessGenerator. But ThisAccessGenerator overrides buildSimpleRead so stack frame #6 should not be possible.

@johnniwinther
Copy link
Member

@mkustermann: To me this looks VM related giving the call stack doesn't match the Dart code.

@mkustermann
Copy link
Member

If this is caused by a VM mis-optimization we would need to be able to reproduce this to find out what's going on.

/cc @a-siva

@mkustermann mkustermann added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Jul 29, 2019
@mraleph
Copy link
Member

mraleph commented Aug 1, 2019

I concur with @johnniwinther's analysis of the problem. This is most likely a VM bug, something related to method dispatch - potentially optimizing compiler related. Given the timing of when it started surfacing it might be related to @rmacnak-google's changes in the method dispatch (enabling switchable calls in the JIT mode).

Ryan, do you have any insight here? You fixed some bugs in the optimizing compiler after landing - does this look like one of those?

@mkustermann
Copy link
Member

mkustermann commented Aug 8, 2019

@jensjoha Pointed out that this happens sometimes on our CQ try jobs as well. For example see this failed build:

# Command: out/ReleaseX64/dart --print_metrics pkg/analyzer_cli/bin/analyzer.dart --dart-sdk=sdk hello.dart
Printing metrics for main
...
isolate.runnable.latency 0.000 us (0 us)
isolate.runnable.heap 0.000 B (0 B)

Unsupported node ShadowFieldInitializer
#0      BytecodeGenerator.defaultTreeNode (package:vm/bytecode/gen_bytecode.dart:2455:33)
#1      TreeVisitor.defaultInitializer (package:kernel/visitor.dart:238:45)
#2      TreeVisitor.visitFieldInitializer (package:kernel/visitor.dart:241:53)
#3      FieldInitializer.accept (package:kernel/ast.dart:1879:37)
#4      BytecodeGenerator._generateNode (package:vm/bytecode/gen_bytecode.dart:917:10)
#5      List.forEach (dart:core-patch/growable_array.dart:283:8)
#6      BytecodeGenerator._generateNodeList (package:vm/bytecode/gen_bytecode.dart:922:11)
#7      BytecodeGenerator._genConstructorInitializers (package:vm/bytecode/gen_bytecode.dart:938:5)
#8      BytecodeGenerator.defaultMember (package:vm/bytecode/gen_bytecode.dart:730:13)
#9      TreeVisitor.visitConstructor (package:kernel/visitor.dart:227:43)

Though so far I was unable to reproduce this issue.

@a-siva
Copy link
Contributor

a-siva commented Aug 8, 2019

@rmacnak-google do you think it makes sense to turn off FLAG_unopt_monomorphic_calls and FLAG_unopt_megamorphic_calls for a week in the VM to see if these sporadic crashes stop when the flags are off. There is of course the issue of having to deal with the hot reload benchmark regressing when we turn off these flags.

@mkustermann
Copy link
Member

I think I've identified the underlying bug.

After 1e24fe7 our optimizing compiler starts to use the megamorphic caches as input for making optimization decisions.

  • For an instance call, the optimizer will look up the current value of the megamorphic cache for that instance call to determine if we have a single target (e.g. a call site calls a method on many different targets, but the method was not overridden for those targets)

  • Once the optimizing compiler determined that we only have a single target, it will insert CheckClass instructions and de-virtualize the instance call into a StaticCall (which then can also be inlined)

We've added locking around the megamorphic cache to prevent mutator and BG compiler accessing it concurrently.

What we've not ensured is that BG compiler always sees a consistent view of the megamorphic cache: The BG compiler consults the megamorphic cache several times during the optimization of a function. Since the mutator is running concurrently, the BG compiler can get different answers each time it looks at the megamorphic cache.

This is precisely what seems to happen here:

  • The megamorphic cache for v.visitFieldInitializer(this) contains several receivers, though none of them overwrite the visitFieldInitializer method. So even though we have multiple receivers, the call will go to the same target (I believe TreeVisitor.visitFieldInitializer).
  • The compiler determins there is only a single target.
  • The mutator now sees a new receiver - BytecodeGenerator going into that callsite, so it adds it to the megamorphic cache.
  • The compiler adds a new class check, which will consult the megamorphic cache again, this time getting an additional receiver class.
  • The compiler adds the devirtualized static call instruction.

Here's a small diff which seems to fix it:

diff --git a/runtime/vm/compiler/call_specializer.h b/runtime/vm/compiler/call_specializer.h
index e9a0a6d580..2b1e4ee25d 100644
--- a/runtime/vm/compiler/call_specializer.h
+++ b/runtime/vm/compiler/call_specializer.h
@@ -117,12 +117,6 @@ class CallSpecializer : public FlowGraphVisitor {
  protected:
   void InlineImplicitInstanceGetter(Definition* call, const Field& field);
 
-  SpeculativeInliningPolicy* speculative_policy_;
-  const bool should_clone_fields_;
-
- private:
-  bool TypeCheckAsClassEquality(const AbstractType& type);
-
   // Insert a check of 'to_check' determined by 'unary_checks'.  If the
   // check fails it will deoptimize to 'deopt_id' using the deoptimization
   // environment 'deopt_environment'.  The check is inserted immediately
@@ -133,6 +127,12 @@ class CallSpecializer : public FlowGraphVisitor {
                      Environment* deopt_environment,
                      Instruction* insert_before);
 
+  SpeculativeInliningPolicy* speculative_policy_;
+  const bool should_clone_fields_;
+
+ private:
+  bool TypeCheckAsClassEquality(const AbstractType& type);
+
   // Insert a Smi check if needed.
   void AddCheckSmi(Definition* to_check,
                    intptr_t deopt_id,
diff --git a/runtime/vm/compiler/jit/jit_call_specializer.cc b/runtime/vm/compiler/jit/jit_call_specializer.cc
index e60517614c..7f013022f1 100644
--- a/runtime/vm/compiler/jit/jit_call_specializer.cc
+++ b/runtime/vm/compiler/jit/jit_call_specializer.cc
@@ -167,7 +167,20 @@ void JitCallSpecializer::VisitInstanceCall(InstanceCallInstr* instr) {
     // Type propagation has not run yet, we cannot eliminate the check.
     // TODO(erikcorry): The receiver check should use the off-heap targets
     // array, not the IC array.
-    AddReceiverCheck(instr);
+
+    // After we determined `targets.HasSingleTarget()` the mutator might have
+    // updated the megamorphic cache by adding more entries with *different*
+    // targets.
+    //
+    // We therefore have to ensure the class check we insert is only valid for
+    // precisely the [targets] classes we have based our decision upon.
+    //
+    // (i.e. we cannot use [AddReceiverCheck]/[AddCheckClass], since it
+    //  internally consults megmorphic cache gain, which can return a superset
+    //  of the classes - possibly with different targets)
+    //
+    AddCheckClass(instr->Receiver()->definition(), targets, instr->deopt_id(), instr->env(), instr);
+
     // Call can still deoptimize, do not detach environment from instr.
     const Function& target =
         Function::ZoneHandle(Z, unary_checks.GetTargetAt(0));

Though there might be more places where the compiler doesn't see a consistent picture of the megamorphic cache.

=> We should ensure that during one compilation, the compiler always sees the megamorphic cache in the same state (similarly to how we do this for ICData).

@rmacnak-google
Copy link
Contributor

Related to #37575

dart-bot pushed a commit that referenced this issue Aug 19, 2019
…idTargets we made the HasSingleTarget decision on

This is a temporary fix until we implement some abstraction to ensure the BG compiler
has always a consistent view of megamorphic caches it's interested in.

Issue #37595

Change-Id: I98ec29db7a4ecd5776f724e11d50fb4535bacdd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113694
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
@mraleph mraleph added this to the D25 Release milestone Aug 19, 2019
@mraleph
Copy link
Member

mraleph commented Aug 19, 2019

Marking this as D25 as the bug itself is in D25 /cc @aadilmaan

@mkustermann mkustermann removed the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Aug 20, 2019
@a-siva
Copy link
Contributor

a-siva commented Aug 20, 2019

A fix from kustermann@ has landed which fixes this issue, we have another issue opened at #37575 for more code health/cleanup work.

@a-siva a-siva closed this as completed Aug 20, 2019
@mraleph
Copy link
Member

mraleph commented Aug 21, 2019

I don't think the issue is resolved - @mkustermann's fix only fixed one race that was reproducible. I think there are more races hiding. I am reopening this and marking this a P0 and D25 blocker.

Here is at least one more race that I found: note that ICData::Clone first clones ICData::entries and then clones megamorphic state bit.

This means that in general due to a race we might end up with a clone that has a single check in entries but is marked as megamorphic (because right after we clone entries mutator might race ahead and add 5 more checks and then mark call site as megamorphic).

This means that some methods in call specializer (as an example TryInlineImplicitInstanceGetter) would produce incorrect inlining - they would generate ClassCheck based on the state of the megamorphic cache, but would generate inlined body based on the state of ICData clone which was monomorphic.

@mraleph mraleph reopened this Aug 21, 2019
@mraleph mraleph changed the title "this.plainNameForRead" compiler crash Races between background compiler and unopt switchable calls implementation Aug 21, 2019
@mraleph mraleph added the P0 A serious issue requiring immediate resolution label Aug 21, 2019
dart-bot pushed a commit that referenced this issue Aug 22, 2019
…ackground compiler thread.

This is to prevent the compiler from becoming confused by mutations from the Dart execution thread.

Bug: #37575
Bug: #37595
Change-Id: I43c42feff54d76b780beb6e8d627f1b1641f4bee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114054
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
@dgrove
Copy link
Contributor

dgrove commented Aug 22, 2019

@rmacnak-google is this issue fixed now?

@rmacnak-google
Copy link
Contributor

The race is much less likely now, but there's still work to rationalize the boundary between runtime and compiler access to type feedback.

@rmacnak-google rmacnak-google added P1 A high priority bug; for example, a single project is unusable or has many test failures and removed P0 A serious issue requiring immediate resolution labels Aug 22, 2019
@mraleph
Copy link
Member

mraleph commented Aug 23, 2019

One known (but indeed much less likely) race remains - @mkustermann said he is going to prepare a quick patch for it.

@mkustermann
Copy link
Member

cl/114322 does that.

dart-bot pushed a commit that referenced this issue Aug 23, 2019
…ng ICData to be megamorphic.

The mutator has to ensure all writes to the ICData are flushed before we set the
megamorphic bit.

Similarly the BG compiler has to ensure (during cloning of ICData) that all
loads from the ICData happen after we've determined whether the megamorphic
bit has been set.

This allows us to maintain the invariant that if the ICData is marked as
megamorphic, the entries in it will have reached FLAG_max_polymorphic_checks.

Issue #37595

Change-Id: Idec7aef8ca1369668f5c9c57b7b32759acbd270d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114322
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
@dgrove
Copy link
Contributor

dgrove commented Aug 23, 2019

Great. Is this closeable at this point?

@mkustermann
Copy link
Member

The known races are fixed, so we can close it.

Though we still need to pursue the refactoring tracked at #37575 to avoid other potential bugs (where the compiler makes decisions purely based on ICData but uses ICData + MegamorphicCache for inserting class checks).

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. P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

9 participants