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

Dart_ExecuteInternalCommand("gc-now") broken on *-precomp-win-* #46061

Closed
ghost opened this issue May 18, 2021 · 6 comments
Closed

Dart_ExecuteInternalCommand("gc-now") broken on *-precomp-win-* #46061

ghost opened this issue May 18, 2021 · 6 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. os-windows type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@ghost
Copy link

ghost commented May 18, 2021

Several test are crashing on precompiled Windows, while calling Dart_ExecuteInternalCommand("gc-now"):

vm/dart_2/unboxed_param_args_descriptor_test broke (Pass -> Crash, expected Pass)
vm/dart_2/unboxed_param_tear_off_test broke (Pass -> Crash, expected Pass)
vm/dart_2/unboxed_param_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_function_callbacks_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_function_gc_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_object_gc_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_regress_37100_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_regress_37511_callbacks_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_regress_37511_test broke (Pass -> Crash, expected Pass)
ffi_2/vmspecific_regress_37780_test broke (Pass -> Crash, expected Pass)

To replicate this, you will currently need to remove a condition as described in #46059, after which the tests above will fail.

Edit: This appears to likewise affect other Dart_ExecuteInternalCommand(..) calls, and probably other functions as well.

@ghost ghost added os-windows type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels May 18, 2021
@ghost
Copy link
Author

ghost commented May 19, 2021

With the caveat that I'm entirely new to debugging on Windows, here are some preliminary findings on this issue.

Reproducing steps:

  1. I did a one-time setup procdump -ma -i c:\dumps to capture crashes.
  2. Built python3 tools/test.py --build -k -n dartkp-win-debug-x64 ffi_2/vmspecific_function_gc_test/2
  3. Ran out\DebugX64\dart_precompiled_runtime.exe --deterministic --optimization-counter-threshold=500 --enable-testing-pragmas --ignore-unrecognized-flags --packages=C:\src\dart\sdk\.packages C:/src/dart/sdk/out/DebugX64/generated_compilations/dartkp-win-debug-x64/tests_ffi_2_vmspecific_function_gc_test/out.aotsnapshot to generate the new dump.

Opening the resulting C:\dump\*.dmp in 'Debug Diagnostic Tool' I then see:

In dart_precompiled_runtime.exe_210519_133507.dmp the Module C:\src\dart\sdk\out\DebugX64\dart.exe 
has caused an access violation exception (0xC0000005) when trying to execute instructions from a 
non-executable address at memory location 0x01301290 on thread 6 

Thread 6:

 0x01301290
dart!dart::Mutex::Lock+e
dart!dart::Scavenger::AbandonRemainingTLAB+8e
dart!dart::Heap::CollectOnNthAllocation+2f
dart!Dart_ExecuteInternalCommand+1f9
ffi_test_functions!MinInt64+15

Which makes it look like an issue with Mutex::Lock.

@ghost
Copy link
Author

ghost commented May 19, 2021

@mraleph this seems like something that might be up your alley. Any ideas what's going on here?

@ghost
Copy link
Author

ghost commented May 19, 2021

The code executing at the time is:

void Mutex::Lock() {
AcquireSRWLockExclusive(&data_.lock_);

Which is Windows API.

My guess is that it's a runtime linking issue (not too dissimilar to #40579), and we end up calling some garbage address where the Win. API should be?

@ghost
Copy link
Author

ghost commented May 19, 2021

On dcharkes' suggestion I tried Debug in VisualStudio.
One unexpected finding there is that ffi_test_function.dll is linked against dart.exe. Which means that when dart_compiled_runtime.exe loads ffi_test_function.dll that in turn loads dart.exe, which seems fishy to me.

More speculation: perhaps we need to produce two different ffi_test_function.dlls - one for each dart binary?

Edit:
Ah, I see the build file says as much:

sdk/runtime/bin/BUILD.gn

Lines 1050 to 1052 in 28c784d

if (is_win) {
# TODO(dartbug.com/40579): This wrongly links in dart.exe on precompiled.
libs = [ "dart.lib" ]

Switching the above line over to dart_precompiled_runtime.lib also fixes the issue, confirming the theory.

@a-siva a-siva added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label May 19, 2021
@ghost ghost self-assigned this May 20, 2021
@mkustermann
Copy link
Member

This issue's title suggests that Dart_ExecuteInternalCommand is broken on *-precomp-win-* - but that function is working fine if used correctly.

Could we close this as duplicate of #40579?

dart-bot pushed a commit that referenced this issue May 21, 2021
This removes the need for passing the flag to use
Dart_ExecuteInternalCommand, which is done in several tests
that otherwise have nothing to do with testing pragmas.

Also adds status file skips for precomp-win targets that currently
crash due to #40579.

TEST=CQ

Bug: #46059, #46061
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-nnbd-win-release-x64-try,vm-kernel-win-debug-x64-try
Change-Id: I3024ad9bedb7a74abaaaa1020b7525e5d8b1bd47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200461
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
@ghost
Copy link
Author

ghost commented May 21, 2021

The specific issue here (and in #46059) has now been addressed, and any remaining work is related to #40579.

This issue was closed.
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. os-windows type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants