Skip to content

Commit

Permalink
[vm/ffi] Fix issue due to unspecified argument evaluation order in C++
Browse files Browse the repository at this point in the history
We already have tests that exercise this, namely:

  - ffi_2/regress_39044_test
  - ffi_2/vmspecific_send_port_id_test

Though the bug only appears if C++ compiler decides to evaluate arguments
in a different order. This happens to be only the case on Windows.

We don't have Windows hardware with Android phones on our CI, which is
why this was not caught earlier.

We have manually confirmed (via building app on windows with this fix
and running on android) that the issue is fixed by this change.

Fixes flutter/flutter#54948

Change-Id: I51109cf1062964a5fb77948cffb9e2ba8fe2055f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149980
Commit-Queue: Martin Kustermann <[email protected]>
Reviewed-by: Daco Harkes <[email protected]>
  • Loading branch information
mkustermann authored and [email protected] committed Jun 4, 2020
1 parent 978342b commit 10df757
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions runtime/vm/compiler/ffi/native_calling_convention.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ class ArgumentAllocator : public ValueObject {
cpu_regs_used += cpu_regs_used % 2;
}
if (cpu_regs_used + 2 <= CallingConventions::kNumArgRegs) {
const Register register_1 = AllocateCpuRegister();
const Register register_2 = AllocateCpuRegister();
return *new (zone_) NativeRegistersLocation(
payload_type, container_type, AllocateCpuRegister(),
AllocateCpuRegister());
payload_type, container_type, register_1, register_2);
}
} else {
ASSERT(payload_type.SizeInBytes() <= target::kWordSize);
Expand Down

0 comments on commit 10df757

Please sign in to comment.