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

Class finalization issue #35885

Open
aartbik opened this Issue Feb 7, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@aartbik
Copy link
Contributor

aartbik commented Feb 7, 2019

Introduced by "[vm] Load top-level functions and variables lazily"
Change-Id: If47f06fe235a70ed08e6a3d75e8f871edae5e45c

FAILED: dartk-vm debug_x64 language_2/inference_enum_list_test
Expected: Pass
Actual: Crash

--- Command "vm" (took 02.000514s):
DART_CONFIGURATION=DebugX64 out/DebugX64/dart --no-background-compilation --hot-reload-test-mode --ignore-unrecognized-flags --packages=/b/s/w/ir/.packages /b/s/w/ir/tests/language_2/inference_enum_list_test.dart

exit code:
-6

stderr:
../../runtime/vm/object.h: 5767: error: expected: cls.is_finalized() || cls.is_prefinalized()
thread=5245, isolate=inference_enum_list_test.dart:main()(0x560cf7af0900)
[0x0000560cf62c52ec] dart::Profiler::DumpStackTrace(void*)
[0x0000560cf62c52ec] dart::Profiler::DumpStackTrace(void*)
[0x0000560cf65828c2] dart::Assert::Fail(char const*, ...)
[0x0000560cf626eb16] Unknown symbol
[0x0000560cf626ebbf] dart::Instance::CanonicalizeHash() const
[0x0000560cf6283db6] dart::Array::CanonicalizeHash() const
[0x0000560cf629acf5] Unknown symbol
[0x0000560cf629aa80] Unknown symbol
[0x0000560cf629a99d] Unknown symbol
[0x0000560cf629a609] Unknown symbol
[0x0000560cf622444e] Unknown symbol
[0x0000560cf6223f22] dart::Class::InsertCanonicalConstant(dart::Zone*, dart::Instance const&) const
[0x0000560cf626f3d7] dart::Instance::CheckAndCanonicalize(dart::Thread*, char const**) const
[0x0000560cf64d672d] dart::kernel::TranslationHelper::Canonicalize(dart::Instance const&)
[0x0000560cf64aaaba] dart::kernel::ConstantEvaluator::EvaluateListLiteralInternal()
[0x0000560cf64a8943] dart::kernel::ConstantEvaluator::EvaluateExpression(long, bool)
[0x0000560cf64b2227] dart::kernel::StreamingFlowGraphBuilder::BuildGraphOfFieldInitializer()
[0x0000560cf64bc52e] dart::kernel::StreamingFlowGraphBuilder::BuildGraph()
[0x0000560cf64d11c7] dart::kernel::FlowGraphBuilder::BuildGraph()
[0x0000560cf650a1f4] dart::DartCompilationPipeline::BuildFlowGraph(dart::Zone*, dart::ParsedFunction*, dart::ZoneGrowableArray<dart::ICData const*>, long, bool)
[0x0000560cf650bf66] dart::CompileParsedFunctionHelper::Compile(dart::CompilationPipeline
)
[0x0000560cf650fba6] dart::Compiler::EvaluateStaticInitializer(dart::Field const&)
[0x0000560cf623c357] dart::Field::EvaluateInitializer() const
[0x0000560cf6119be0] dart::ClassFinalizer::AllocateEnumValues(dart::Class const&)
[0x0000560cf61193ff] dart::ClassFinalizer::FinalizeClass(dart::Class const&)
[0x0000560cf611a514] dart::ClassFinalizer::LoadClassMembers(dart::Class const&)
[0x0000560cf620f857] dart::Class::EnsureIsFinalized(dart::Thread*) const
[0x0000560cf62ac72a] dart::Class::CheckReload(dart::Class const&, dart::IsolateReloadContext*) const
[0x0000560cf61baf63] dart::IsolateReloadContext::ValidateReload()
[0x0000560cf61ba041] dart::IsolateReloadContext::FinalizeLoading()
[0x0000560cf61b82bd] dart::IsolateReloadContext::Reload(bool, char const*, char const*, unsigned char const*, long)
[0x0000560cf61ae135] dart::Isolate::ReloadSources(dart::JSONStream*, bool, char const*, char const*, bool)
[0x0000560cf6330ca0] dart::DRT_StackOverflow(dart::NativeArguments)
[0x00007fd709341037] Unknown symbol
[0x00007fd705682fd6] Unknown symbol
[0x00007fd7056b260a] Unknown symbol
[0x00007fd7056b24e8] Unknown symbol
[0x00007fd7056a96fe] Unknown symbol
[0x00007fd7056b16da] Unknown symbol
[0x00007fd70568a4a1] Unknown symbol
[0x00007fd7056b1398] Unknown symbol
[0x00007fd70934153a] Unknown symbol
[0x0000560cf61686c3] dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
[0x0000560cf616b8f1] dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
[0x0000560cf61a973e] dart::IsolateMessageHandler::HandleMessage(dart::Message*)
[0x0000560cf61e9d78] dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
[0x0000560cf61eaae6] dart::MessageHandler::TaskCallback()
[0x0000560cf638818c] dart::ThreadPool::Worker::Loop()
[0x0000560cf6387c6b] dart::ThreadPool::Worker::Main(unsigned long)
[0x0000560cf62befa5] Unknown symbol
-- End of DumpStackTrace

@aartbik aartbik added the area-vm label Feb 7, 2019

dart-bot pushed a commit that referenced this issue Feb 7, 2019

[dart/vm] Skip finalization error for now
#35885

Change-Id: I4d46badddd211b859a7724c4030f83996a5877c9
Reviewed-on: https://dart-review.googlesource.com/c/92402
Commit-Queue: Aart Bik <ajcbik@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
@aartbik

This comment has been minimized.

Copy link
Contributor Author

aartbik commented Feb 7, 2019

Does not reproduce for me locally. Even when running the full suite.

$ python tools/test.py -n dartk-reload-linux-debug-x64 language_2/inference_enum_list_test
tools/testing/dart/main.dart:1: Warning: Interpreting this as package URI, 'package:test_dart/main.dart'.
Test configuration:
    dartk-reload-linux-debug-x64(architecture: x64, compiler: dartk, mode: debug, runtime: vm, system: linux, vm-options: [], timeout: null, preview-dart-2, hot-reload)
Suites tested: language_2
[00:01 | 100% | +    1 | -    0]

dart-bot pushed a commit that referenced this issue Feb 7, 2019

[dart/vm] Skip finalization error for now
#35885

Change-Id: I79a1c77459b1cf1cdae563cd6e29697e641a57ff
Reviewed-on: https://dart-review.googlesource.com/c/92385
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
@alexmarkov

This comment has been minimized.

Copy link
Contributor

alexmarkov commented Feb 8, 2019

This test has the following code:

enum E1 { a, b }
enum E2 { a, b }

var v = [E1.a, E2.b];

During validation of hot reload (IsolateReloadContext::ValidateReload, Class::CheckReload) finalization happens in certain order (in this case E1, E2). While finalizing enum class E1, initializers of its fields are invoked, which includes initializer for values field:

static const field core::List<inf::E1> values = const <inf::E1>[inf::E1::a, inf::E1::b];

That initializer canonicalizes a new Array constant. While doing this, constants() hash table in Array class grows and rehashes, which causes rehashing of all constant objects of Array class. This includes values array from E2 ([E2.a, E2.b], which contains references to instances of E2, but enum class E2 is not finalized yet. Hence the assertion.

More detailed stack trace:

#1  0x000055b7789e78c7 in dart::Assert::Fail (this=<optimized out>, format=<optimized out>) at ../../runtime/platform/assert.cc:43
#2  0x000055b7786d3b16 in dart::Instance::SizeFromClass (this=0x55b77aa427d0) at ../../runtime/vm/object.h:5767
#3  0x000055b7786d3bbf in dart::Instance::CanonicalizeHash (this=0x55b77aa427d0) at ../../runtime/vm/object.cc:15850
#4  0x000055b7786e8db6 in dart::Array::CanonicalizeHash (this=0x55b77aa42360) at ../../runtime/vm/object.cc:20056
#5  0x000055b7786ffcf5 in dart::CanonicalInstanceTraits::Hash (key=...) at ../../runtime/vm/object.cc:4741
#6  0x000055b7786ffa80 in dart::HashTable<dart::CanonicalInstanceTraits, 0l, 0l>::FindKeyOrDeletedOrUnused<dart::Object> (this=0x7ff56597b2e0, key=..., 
    entry=0x7ff56597b270) at ../../runtime/vm/hash_table.h:193
#7  0x000055b7786ff99d in dart::HashTables::Copy<dart::HashSet<dart::UnorderedHashTable<dart::CanonicalInstanceTraits, 0l> >, dart::HashSet<dart::UnorderedHashTable<dart::CanonicalInstanceTraits, 0l> > > (from=..., to=...) at ../../runtime/vm/hash_table.h:469
#8  0x000055b7786ff609 in dart::HashTables::EnsureLoadFactor<dart::HashSet<dart::UnorderedHashTable<dart::CanonicalInstanceTraits, 0l> > > (high=<optimized out>, 
    table=...) at ../../runtime/vm/hash_table.h:503
#9  0x000055b77868944e in EnsureCapacity (this=0x7ff56597b398) at ../../runtime/vm/hash_table.h:703
#10 dart::HashSet<dart::UnorderedHashTable<dart::CanonicalInstanceTraits, 0l> >::InsertNewOrGet<dart::CanonicalInstanceKey> (this=0x7ff56597b398, key=...)
    at ../../runtime/vm/hash_table.h:666
#11 0x000055b778688f22 in dart::Class::InsertCanonicalConstant (this=<optimized out>, zone=<optimized out>, constant=...) at ../../runtime/vm/object.cc:4775
#12 0x000055b7786d43d7 in dart::Instance::CheckAndCanonicalize (this=0x55b77aa416b0, thread=<optimized out>, error_str=<optimized out>)
    at ../../runtime/vm/object.cc:15955
#13 0x000055b77893b72d in dart::kernel::TranslationHelper::Canonicalize (this=0x7ff56597baf8, instance=...)
    at ../../runtime/vm/compiler/frontend/kernel_translation_helper.cc:307
#14 0x000055b77890faba in dart::kernel::ConstantEvaluator::EvaluateListLiteralInternal (this=0x7ff56597b888)
    at ../../runtime/vm/compiler/frontend/constant_evaluator.cc:715
#15 0x000055b77890d943 in dart::kernel::ConstantEvaluator::EvaluateExpression (this=0x7ff56597b888, offset=72, reset_position=true)
    at ../../runtime/vm/compiler/frontend/constant_evaluator.cc:107
#16 0x000055b778917227 in dart::kernel::StreamingFlowGraphBuilder::BuildGraphOfFieldInitializer (this=0x7ff56597b7e0)
    at ../../runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc:58
#17 0x000055b77892152e in dart::kernel::StreamingFlowGraphBuilder::BuildGraph (this=0x7ff56597b7e0)
    at ../../runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc:2015
#18 0x000055b7789361c7 in dart::kernel::FlowGraphBuilder::BuildGraph (this=0x7ff56597ba80) at ../../runtime/vm/compiler/frontend/kernel_to_il.cc:722
#19 0x000055b77896f1f4 in dart::DartCompilationPipeline::BuildFlowGraph (this=<optimized out>, zone=<optimized out>, parsed_function=<optimized out>, 
    ic_data_array=<optimized out>, osr_id=<optimized out>, optimized=<optimized out>) at ../../runtime/vm/compiler/jit/compiler.cc:152
#20 0x000055b778970f66 in dart::CompileParsedFunctionHelper::Compile (this=0x7ff56597cd00, pipeline=0x7ff56597ccf8)
    at ../../runtime/vm/compiler/jit/compiler.cc:620
#21 0x000055b778974ba6 in dart::Compiler::EvaluateStaticInitializer (field=...) at ../../runtime/vm/compiler/jit/compiler.cc:1239
#22 0x000055b7786a1357 in dart::Field::EvaluateInitializer (this=0x55b77aa40e90) at ../../runtime/vm/object.cc:8499
#23 0x000055b77857ebe0 in dart::ClassFinalizer::AllocateEnumValues (enum_cls=...) at ../../runtime/vm/class_finalizer.cc:1240
#24 0x000055b77857e3ff in dart::ClassFinalizer::FinalizeClass (cls=...) at ../../runtime/vm/class_finalizer.cc:1173
#25 0x000055b77857f514 in dart::ClassFinalizer::LoadClassMembers (cls=...) at ../../runtime/vm/class_finalizer.cc:1181
#26 0x000055b778674857 in dart::Class::EnsureIsFinalized (this=0x55b77aa3d290, thread=0x55b77a41f400) at ../../runtime/vm/object.cc:3448
#27 0x000055b77871172a in dart::Class::CheckReload (this=0x55b77aa3d280, replacement=..., context=0x55b77a3fe600) at ../../runtime/vm/object_reload.cc:581
---Type <return> to continue, or q <return> to quit---
#28 0x000055b77861ff63 in dart::IsolateReloadContext::ValidateReload (this=0x55b77a3fe600) at ../../runtime/vm/isolate_reload.cc:1776
#29 0x000055b77861f041 in dart::IsolateReloadContext::FinalizeLoading (this=0x55b77a3fe600) at ../../runtime/vm/isolate_reload.cc:845
#30 0x000055b77861d2bd in dart::IsolateReloadContext::Reload (this=0x7ff56597db08, force_reload=false, root_script_url=<optimized out>, 
    packages_url_=0x6597f601 <error: Cannot access memory at address 0x6597f601>, kernel_buffer=0x55b77af24c01 "\253\315\357", kernel_buffer_size=1448)
    at ../../runtime/vm/isolate_reload.cc:768
#31 0x000055b778613135 in dart::Isolate::ReloadSources (this=0x55b77a405200, js=0x7ff56597dc78, force_reload=true, 
    root_script_url=0x7ff56597d3f0 "file:///b/s/w/ir/tests/language_2/inference_enum_list_test.dart", packages_url=0x0, dont_delete_reload_context=false)
    at ../../runtime/vm/isolate.cc:1288

/cc @rmacnak-google

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment