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

Failures on [vm/ffi] Closure callbacks for async callbacks #53056

Closed
alexmarkov opened this issue Jul 27, 2023 · 2 comments
Closed

Failures on [vm/ffi] Closure callbacks for async callbacks #53056

alexmarkov opened this issue Jul 27, 2023 · 2 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. gardening type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@alexmarkov
Copy link
Contributor

There are new test failures on [vm/ffi] Closure callbacks for async callbacks.

The tests

ffi/async_void_function_callbacks_test/8 Crash (expected Pass)

are failing on configurations

dartkp-weak-asserts-linux-release-x64
vm-aot-android-release-arm64c
vm-aot-android-release-arm_x64
vm-aot-dwarf-linux-product-x64
vm-aot-linux-debug-x64
vm-aot-linux-debug-x64c
vm-aot-linux-product-x64
vm-aot-linux-release-arm-qemu
vm-aot-linux-release-arm64
vm-aot-linux-release-riscv64-qemu
vm-aot-linux-release-x64
vm-aot-mac-product-arm64
vm-aot-mac-release-arm64
vm-aot-mac-release-x64
vm-aot-obfuscate-linux-release-x64
vm-aot-win-debug-arm64
vm-aot-win-debug-x64c
vm-aot-win-product-x64
vm-aot-win-release-arm64
vm-aot-win-release-x64

Log:

--- Command "vm_compile_to_kernel" (took 03.000865s):
DART_CONFIGURATION=ReleaseX64 /b/s/w/ir/pkg/vm/tool/gen_kernel --aot --platform=out/ReleaseX64/vm_platform_strong.dill -o /b/s/w/ir/out/ReleaseX64/generated_compilations/vm-aot-linux-release-x64/tests_ffi_async_void_function_callbacks_test.dart_8/out.dill /b/s/w/ir/tests/ffi/async_void_function_callbacks_test.dart -Dtest_runner.configuration=vm-aot-linux-release-x64 --packages=/b/s/w/ir/.dart_tool/package_config.json -Ddart.vm.product=false --sound-null-safety

exit code:
0

--- Command "precompiler" (took 435ms):
DART_CONFIGURATION=ReleaseX64 out/ReleaseX64/gen_snapshot --snapshot-kind=app-aot-assembly --assembly=/b/s/w/ir/out/ReleaseX64/generated_compilations/vm-aot-linux-release-x64/tests_ffi_async_void_function_callbacks_test.dart_8/out.S --sound-null-safety --test_il_serialization -Dtest_runner.configuration=vm-aot-linux-release-x64 --ignore-unrecognized-flags --packages=/b/s/w/ir/.dart_tool/package_config.json /b/s/w/ir/out/ReleaseX64/generated_compilations/vm-aot-linux-release-x64/tests_ffi_async_void_function_callbacks_test.dart_8/out.dill

exit code:
-6

stderr:
../../runtime/vm/compiler/backend/il_serializer.cc: 2133: error: unimplemented code
version=3.2.0-edge.edeac698c242e06cc5e961001a4209cbc9ab050b (be) (Wed Jul 26 23:23:26 2023 +0000) on "linux_x64"
pid=181262, thread=181262, isolate_group=isolate(0x562cdf05e1a0), isolate=(nil)((nil))
os=linux, arch=x64, comp=no, sim=no
isolate_instructions=0, vm_instructions=0
fp=7ffc6589f8f0, sp=7ffc6589f7b8, pc=562cdd4c3e9c
  pc 0x0000562cdd4c3e9c fp 0x00007ffc6589f8f0 dart::Profiler::DumpStackTrace(void*)+0x7c
  pc 0x0000562cdd356f34 fp 0x00007ffc6589f9d0 dart::Assert::Fail(char const*, ...) const+0x84
  pc 0x0000562cdd86c6e8 fp 0x00007ffc6589fa60 dart::FlowGraphDeserializer::ReadObjectImpl(long, long)+0x37a8
  pc 0x0000562cdd85de60 fp 0x00007ffc6589fad0 dart::FlowGraphDeserializer::ReadTrait<dart::Function const&, void>::Read(dart::FlowGraphDeserializer*)+0xbe0
  pc 0x0000562cdd85e9e2 fp 0x00007ffc6589fb20 dart::FlowGraphDeserializer::ReadTrait<dart::Object const&, void>::Read(dart::FlowGraphDeserializer*)+0x92
  pc 0x0000562cdd8653a8 fp 0x00007ffc6589fb40 out/ReleaseX64/gen_snapshot+0xad33a8
  pc 0x0000562cdd85fb92 fp 0x00007ffc6589fb70 dart::FlowGraphDeserializer::ReadTrait<dart::Instruction*, void>::Read(dart::FlowGraphDeserializer*)+0xcf2
  pc 0x0000562cdd870708 fp 0x00007ffc6589fba0 out/ReleaseX64/gen_snapshot+0xade708
  pc 0x0000562cdd85e0c2 fp 0x00007ffc6589fbe0 dart::GraphEntryInstr::GraphEntryInstr(dart::FlowGraphDeserializer*)+0x32
  pc 0x0000562cdd85ef34 fp 0x00007ffc6589fc10 dart::FlowGraphDeserializer::ReadTrait<dart::Instruction*, void>::Read(dart::FlowGraphDeserializer*)+0x94
  pc 0x0000562cdd85c983 fp 0x00007ffc6589fcc0 dart::FlowGraphDeserializer::ReadFlowGraph()+0x373
  pc 0x0000562cdd8d12cb fp 0x00007ffc6589fe20 out/ReleaseX64/gen_snapshot+0xb3f2cb
  pc 0x0000562cdd8d00f0 fp 0x00007ffc6589fee0 dart::CompilerPass::Run(dart::CompilerPassState*) const+0x120
  pc 0x0000562cdd8d0885 fp 0x00007ffc6589ff00 dart::CompilerPass::RunPipeline(dart::CompilerPass::PipelineMode, dart::CompilerPassState*)+0x355
  pc 0x0000562cdd7ec8dc fp 0x00007ffc658a05a0 dart::PrecompileParsedFunctionHelper::Compile(dart::CompilationPipeline*)+0x59c
  pc 0x0000562cdd7ed155 fp 0x00007ffc658a0c60 out/ReleaseX64/gen_snapshot+0xa5b155
  pc 0x0000562cdd7e95e7 fp 0x00007ffc658a0d70 dart::Precompiler::CompileFunction(dart::Precompiler*, dart::Thread*, dart::Zone*, dart::Function const&)+0x177
  pc 0x0000562cdd4ceaa8 fp 0x00007ffc658a0db0 out/ReleaseX64/gen_snapshot+0x73caa8
  pc 0x0000562cdd4ce793 fp 0x00007ffc658a0ec0 dart::ProgramVisitor::WalkProgram(dart::Zone*, dart::IsolateGroup*, dart::ClassVisitor*)+0x453
  pc 0x0000562cdd7e2bc2 fp 0x00007ffc658a0f50 dart::Precompiler::PrecompileConstructors()+0x62
  pc 0x0000562cdd7e01f8 fp 0x00007ffc658a1650 dart::Precompiler::DoCompileAll()+0x2d8
  pc 0x0000562cdd7dfeb8 fp 0x00007ffc658a1ae0 dart::Precompiler::CompileAll()+0xb8
  pc 0x0000562cdd9758ce fp 0x00007ffc658a1c40 Dart_Precompile+0x24e
  pc 0x0000562cdd334aac fp 0x00007ffc658a1dd0 dart::bin::main(int, char**)+0x8dc
-- End of DumpStackTrace
=== Crash occurred when compiling file:///b/s/w/ir/tests/ffi/async_void_function_callbacks_test.dart_Callbacks_Callbacks. in AOT mode in ReorderBlocks pass
*** BEGIN CFG
ReorderBlocks
==== file:///b/s/w/ir/tests/ffi/async_void_function_callbacks_test.dart_Callbacks_Callbacks. (Constructor)
  0: B0[graph]:0 {
      v0 <- Constant(#null) T{Null?}
      v2 <- Constant(#TypeArguments: (H33442dcf) [(dynamic, Int64, Int32) => Void]) T{TypeArguments}
      v3 <- Constant(#Function '<anonymous closure>':.) T{Function}
      v4 <- Constant(#NativeCallable(ConstantExpression(addGlobalVar))) T{_OneByteString}
      v5 <- Constant(#TypeArguments: (H3cfea33e) [Type: NativeFunction<(dynamic, Int64, Int32) => Void>]) T{TypeArguments}
      v6 <- Constant(#Function '_FfiAsyncCallback': static ffi-trampoline-function.) T{Function}
      v7 <- Constant(#Function '<anonymous closure>':.) T{Function}
      v8 <- Constant(#NativeCallable(ConstantExpression(callFromIsoBToAAndMultByGlobalVar))) T{_OneByteString}
      v9 <- Constant(#Function '<anonymous closure>':.) T{Function}
      v10 <- Constant(#NativeCallable(ConstantExpression(callFromIsoAToBAndMultByGlobalVar))) T{_OneByteString}
      v12 <- Constant(#Type: Pointer<NativeFunction<(dynamic, Int64, Int32) => Void>>) T{_Type}
}
  2: B1[function entry]:2 {
      v13 <- Parameter(0) T{Callbacks}
}
  4:     CheckStackOverflow:8(stack=0, loop=0)
  5:     ParallelMove rdx <- C
  6:     v14 <- AllocateObject:12(cls=NativeCallable, v2) T{NativeCallable}
  7:     ParallelMove rbx <- C, rdx <- C, rax <- rax
  8:     ParallelMove S-1 <- rax
  8:     v15 <- AllocateClosure:14(v3, v0) T{_Closure}
 10:     MoveArgument(v14, SP+2)
 12:     MoveArgument(v15, SP+1)
 14:     MoveArgument(v4, SP+0)
 16:     StaticCall:16( NativeCallable._@8050071<0> v14, v15, v4)
 17:     ParallelMove rax <- S-1
 18:     v16 <- LoadField(v14 . _port@8050071 {final}) T{_RawReceivePort}
 20:     MoveArgument(v5, SP+2)
 22:     MoveArgument(v6, SP+1)
 24:     MoveArgument(v16, SP+0)
 26:     v17 <- StaticCall:20( _pointerAsyncFromFunction@8050071<1> v5, v6, v16, result_type = T{Pointer}) T{Pointer}
 27:     ParallelMove rax <- rax, rdx <- C, rcx <- C, rbx <- rax
 28:     ParallelMove S-2 <- rbx
 28:     AssertAssignable:4(v17 T{Pointer}, v12 T{_Type}, 'value', instantiator_type_args(v0 T{Null}), function_type_args(v0 T{Null?})) T{Pointer}
 29:     ParallelMove rax <- S-2, rcx <- S-1
 30:     StoreField(v14 T{NativeCallable} . _pointer@8050071 = v17)
 31:     ParallelMove rax <- rcx, rcx <- S+2
 32:     StoreField(v13 . addGlobalVarFn = v14)
 33:     ParallelMove rdx <- C
 34:     v18 <- AllocateObject:24(cls=NativeCallable, v2) T{NativeCallable}
 35:     ParallelMove rbx <- C, rdx <- C, rax <- rax
 36:     ParallelMove S-1 <- rax
 36:     v19 <- AllocateClosure:26(v7, v0) T{_Closure}
 38:     MoveArgument(v18, SP+2)
 40:     MoveArgument(v19, SP+1)
 42:     MoveArgument(v8, SP+0)
 44:     StaticCall:28( NativeCallable._@8050071<0> v18, v19, v8)
 45:     ParallelMove rax <- S-1
 46:     v20 <- LoadField(v18 . _port@8050071 {final}) T{_RawReceivePort}
 48:     MoveArgument(v5, SP+2)
 50:     MoveArgument(v6, SP+1)
 52:     MoveArgument(v20, SP+0)
 54:     v21 <- StaticCall:32( _pointerAsyncFromFunction@8050071<1> v5, v6, v20, result_type = T{Pointer}) T{Pointer}
 55:     ParallelMove rax <- rax, rdx <- C, rcx <- C, rbx <- rax
 56:     ParallelMove S-2 <- rbx
 56:     AssertAssignable:4(v21 T{Pointer}, v12 T{_Type}, 'value', instantiator_type_args(v0 T{Null}), function_type_args(v0 T{Null?})) T{Pointer}
 57:     ParallelMove rax <- S-2, rcx <- S-1
 58:     StoreField(v18 T{NativeCallable} . _pointer@8050071 = v21)
 59:     ParallelMove rax <- rcx, rcx <- S+2
 60:     StoreField(v13 . callFromIsoBToAAndMultByGlobalVarFn = v18)
 61:     ParallelMove rdx <- C
 62:     v22 <- AllocateObject:36(cls=NativeCallable, v2) T{NativeCallable}
 63:     ParallelMove rbx <- C, rdx <- C, rax <- rax
 64:     ParallelMove S-1 <- rax
 64:     v23 <- AllocateClosure:38(v9, v0) T{_Closure}
 66:     MoveArgument(v22, SP+2)
 68:     MoveArgument(v23, SP+1)
 70:     MoveArgument(v10, SP+0)
 72:     StaticCall:40( NativeCallable._@8050071<0> v22, v23, v10)
 73:     ParallelMove rax <- S-1
 74:     v24 <- LoadField(v22 . _port@8050071 {final}) T{_RawReceivePort}
 76:     MoveArgument(v5, SP+2)
 78:     MoveArgument(v6, SP+1)
 80:     MoveArgument(v24, SP+0)
 82:     v25 <- StaticCall:44( _pointerAsyncFromFunction@8050071<1> v5, v6, v24, result_type = T{Pointer}) T{Pointer}
 83:     ParallelMove rax <- rax, rdx <- C, rcx <- C, rbx <- rax
 84:     ParallelMove S-2 <- rbx
 84:     AssertAssignable:4(v25 T{Pointer}, v12 T{_Type}, 'value', instantiator_type_args(v0 T{Null}), function_type_args(v0 T{Null?})) T{Pointer}
 85:     ParallelMove rax <- S-2, rcx <- S-1
 86:     StoreField(v22 T{NativeCallable} . _pointer@8050071 = v25)
 87:     ParallelMove rax <- rcx, rcx <- S+2
 88:     StoreField(v13 . callFromIsoAToBAndMultByGlobalVarFn = v22)
 89:     ParallelMove rax <- C
 90:     Return:52(v0)
*** END CFG

--- Re-run this test:
python3 tools/test.py -n vm-aot-linux-release-x64 ffi/async_void_function_callbacks_test/8

@liamappelbe Could you take a look?

@alexmarkov alexmarkov added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) gardening labels Jul 27, 2023
@alexmarkov
Copy link
Contributor Author

edeac69 introduced a mismatch between IL serialization and deserialization for FFI trampolines.

Fix: https://dart-review.googlesource.com/c/sdk/+/316601

@liamappelbe
Copy link
Contributor

Oops. I searched for all occurrences of all variations of callback_target == Object::null(), but I forgot about callback_target.IsNull()

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. gardening type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants