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

[vm/ffi] const Pointer() crashes VM (2 ways) #37396

Closed
sjindel-google opened this issue Jun 28, 2019 · 5 comments
Closed

[vm/ffi] const Pointer() crashes VM (2 ways) #37396

sjindel-google opened this issue Jun 28, 2019 · 5 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi

Comments

@sjindel-google
Copy link
Contributor

Dart:

import 'dart:ffi';

main() {
  Pointer<Int64> ptr = const Pointer();
  ptr.store(1);
}

Crash in Release mode:

../../runtime/vm/object.cc: 18631: error: unreachable code
version=2.5.0-edge.9ae79e26bc01d7ed66b57d3aca7614ac23f83c47 (Fri Jun 28 09:37:35 2019 +0000) on "linux_x64"
thread=243778, isolate=main(0x55940c1de100)
  pc 0x000055940af1f32c fp 0x00007fd69783e560 dart::Profiler::DumpStackTrace(void*)
  pc 0x000055940abff8e2 fp 0x00007fd69783e640 dart::Assert::Fail(char const*, ...)
  pc 0x000055940aef0233 fp 0x00007fd69783e660 out/ReleaseX64/dart+0x1820233
  pc 0x000055940adca706 fp 0x00007fd69783e700 dart::BootstrapNatives::DN_Ffi_store(_Dart_NativeArguments*)
  pc 0x00007fd699b4129f fp 0x00007fd69783e748 Unknown symbol
  pc 0x00007fd69682e1d6 fp 0x00007fd69783e790 Unknown symbol
  pc 0x00007fd69682e102 fp 0x00007fd69783e7d0 Unknown symbol
  pc 0x00007fd69682dea7 fp 0x00007fd69783e810 Unknown symbol
  pc 0x00007fd69682dcd7 fp 0x00007fd69783e848 Unknown symbol
  pc 0x00007fd69682ceff fp 0x00007fd69783e890 Unknown symbol
  pc 0x00007fd69680a51a fp 0x00007fd69783e8d0 Unknown symbol
  pc 0x00007fd69682cbce fp 0x00007fd69783e908 Unknown symbol
  pc 0x00007fd699b4166c fp 0x00007fd69783e978 Unknown symbol
  pc 0x000055940ae0c296 fp 0x00007fd69783ea20 dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
  pc 0x000055940ae0f746 fp 0x00007fd69783ea80 dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
  pc 0x000055940ae48c52 fp 0x00007fd69783ec80 dart::IsolateMessageHandler::HandleMessage(std::__2::unique_ptr<dart::Message, std::__2::default_delete<dart::Message> >)
  pc 0x000055940ae7c25d fp 0x00007fd69783ecf0 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
  pc 0x000055940ae7c9e6 fp 0x00007fd69783ed50 dart::MessageHandler::TaskCallback()
  pc 0x000055940afb3977 fp 0x00007fd69783ed80 dart::ThreadPool::Worker::Loop()
  pc 0x000055940afb3815 fp 0x00007fd69783edc0 dart::ThreadPool::Worker::Main(unsigned long)
  pc 0x000055940af1baa9 fp 0x00007fd69783ee70 out/ReleaseX64/dart+0x184baa9
-- End of DumpStackTrace

Crash in Debug mode:

../../runtime/vm/object.cc: 16470: error: expected: !has_pointers.has_pointers()
version=2.5.0-edge.9ae79e26bc01d7ed66b57d3aca7614ac23f83c47 (Fri Jun 28 09:37:35 2019 +0000) on "linux_x64"
thread=244043, isolate=main(0x560078f14100)
  pc 0x0000560076b415ec fp 0x00007f777b003e80 dart::Profiler::DumpStackTrace(void*)
  pc 0x0000560076767312 fp 0x00007f777b003f60 dart::Assert::Fail(char const*, ...)
  pc 0x0000560076ae7ebb fp 0x00007f777b003fe0 dart::Instance::CheckAndCanonicalizeFields(dart::Thread*, char const**) const
  pc 0x0000560076ae7fb9 fp 0x00007f777b004040 dart::Instance::CheckAndCanonicalize(dart::Thread*, char const**) const
  pc 0x0000560076d80bcd fp 0x00007f777b004070 dart::kernel::TranslationHelper::Canonicalize(dart::Instance const&)
  pc 0x0000560076d5143b fp 0x00007f777b0040d0 dart::kernel::ConstantEvaluator::EvaluateConstructorInvocationInternal()
  pc 0x0000560076d5381e fp 0x00007f777b004110 dart::kernel::ConstantEvaluator::EvaluateConstructorInvocation(long, bool)
  pc 0x0000560076d62ef5 fp 0x00007f777b0041b0 dart::kernel::StreamingFlowGraphBuilder::BuildConstructorInvocation(bool, dart::TokenPosition*)
  pc 0x0000560076d599ea fp 0x00007f777b004200 dart::kernel::StreamingFlowGraphBuilder::BuildExpression(dart::TokenPosition*)
  pc 0x0000560076d6a13e fp 0x00007f777b004290 dart::kernel::StreamingFlowGraphBuilder::BuildVariableDeclaration()
  pc 0x0000560076d5b586 fp 0x00007f777b0042d0 dart::kernel::StreamingFlowGraphBuilder::BuildStatement()
  pc 0x0000560076d65b38 fp 0x00007f777b004330 dart::kernel::StreamingFlowGraphBuilder::BuildBlock()
  pc 0x0000560076d5b5ad fp 0x00007f777b004370 dart::kernel::StreamingFlowGraphBuilder::BuildStatement()
  pc 0x0000560076d5d1cd fp 0x00007f777b004400 dart::kernel::StreamingFlowGraphBuilder::BuildFunctionBody(dart::Function const&, dart::LocalVariable*, bool)
  pc 0x0000560076d5d87e fp 0x00007f777b0045c0 dart::kernel::StreamingFlowGraphBuilder::BuildGraphOfFunction(bool)
  pc 0x0000560076d5dee1 fp 0x00007f777b0047b0 dart::kernel::StreamingFlowGraphBuilder::BuildGraph()
  pc 0x0000560076d7370a fp 0x00007f777b004a40 dart::kernel::FlowGraphBuilder::BuildGraph()
  pc 0x0000560076da1534 fp 0x00007f777b004c30 dart::DartCompilationPipeline::BuildFlowGraph(dart::Zone*, dart::ParsedFunction*, dart::ZoneGrowableArray<dart::ICData const*>*, long, bool)
  pc 0x0000560076da31cf fp 0x00007f777b0052d0 dart::CompileParsedFunctionHelper::Compile(dart::CompilationPipeline*)
  pc 0x0000560076da44d5 fp 0x00007f777b005500 out/DebugX64/dart+0x1c9a4d5
  pc 0x0000560076da3dfd fp 0x00007f777b0055a0 dart::Compiler::CompileFunction(dart::Thread*, dart::Function const&)
  pc 0x0000560076da1b11 fp 0x00007f777b005650 dart::DRT_CompileFunction(dart::NativeArguments)
  pc 0x00007f777cdc1197 fp 0x00007f777b005690 Unknown symbol
  pc 0x00007f777cdc1204 fp 0x00007f777b0056c0 Unknown symbol
  pc 0x00007f7779cefea7 fp 0x00007f777b005700 Unknown symbol
  pc 0x00007f7779cefcb7 fp 0x00007f777b005738 Unknown symbol
  pc 0x00007f7779ceee7f fp 0x00007f777b005780 Unknown symbol
  pc 0x00007f7779ccb01a fp 0x00007f777b0057c0 Unknown symbol
  pc 0x00007f7779ceeb4e fp 0x00007f777b0057f8 Unknown symbol
  pc 0x00007f777cdc173a fp 0x00007f777b005868 Unknown symbol
  pc 0x00005600769c9425 fp 0x00007f777b005910 dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
  pc 0x00005600769cc711 fp 0x00007f777b005980 dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
  pc 0x0000560076a18139 fp 0x00007f777b005b80 dart::IsolateMessageHandler::HandleMessage(std::__2::unique_ptr<dart::Message, std::__2::default_delete<dart::Message> >)
  pc 0x0000560076a5ab70 fp 0x00007f777b005c10 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
  pc 0x0000560076a5b986 fp 0x00007f777b005c90 dart::MessageHandler::TaskCallback()
  pc 0x0000560076bfe86c fp 0x00007f777b005ce0 dart::ThreadPool::Worker::Loop()
  pc 0x0000560076bfe354 fp 0x00007f777b005d30 dart::ThreadPool::Worker::Main(unsigned long)
  pc 0x0000560076b3b435 fp 0x00007f777b005e70 out/DebugX64/dart+0x1a31435
-- End of DumpStackTrace
Aborted
@sjindel-google sjindel-google added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi labels Jun 28, 2019
@sjindel-google
Copy link
Contributor Author

/cc @dcharkes @mkustermann @mraleph

@mkustermann
Copy link
Member

Why does the Pointer class have a const constructor?

@sjindel-google
Copy link
Contributor Author

sjindel-google commented Jun 28, 2019

All NativeTypes have const constructors so they can be used in annotations for structs:

class S extends Struct<S> {
  @Pointer<S>()
  Pointer<S> next;
}

However, the Pointer annotation actually carries no additional information, since it's the same as the type of the field itself.

@sjindel-google
Copy link
Contributor Author

@dcharkes How do you feel about removing the const Pointer annotation altogether?

@dcharkes
Copy link
Contributor

dcharkes commented Jul 4, 2019

Yes, let's remove it.

@dcharkes dcharkes self-assigned this Jul 8, 2019
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. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. library-ffi
Projects
None yet
Development

No branches or pull requests

3 participants