dart-sdk/tests/ffi_2/regress_47594_test.dart
Clement Skau bd4a27ff81 [vm/ffi] Adds transition information to FFI leaf calls.
This change sets `top_exit_frame_info` and `vmtag` on FFI leaf calls.
We have to set this info on the thread so that the stack walker can
interpret the frame correctly.
Without it, anyone trying to walk the stack during an FFI leaf call
- like the profiler - will misinterpret the top frame and cause
a segfault.

TEST=Added regression test.

Bug: https://github.com/dart-lang/sdk/issues/47594
Change-Id: If83aeab194aa0213aee82558bb9541cd7294a935
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220360
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2021-11-29 10:12:36 +00:00

23 lines
781 B
Dart

// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// Regression test for http://dartbug.com/47594.
// FFI leaf calls did not mark the thread for the transition and would cause
// the stack walker to segfault when it was unable to interpret the frame.
//
// VMOptions=--deterministic --enable-vm-service --profiler
import 'dart:ffi';
import 'package:ffi/ffi.dart';
final strerror = DynamicLibrary.process()
.lookupFunction<Pointer<Utf8> Function(Int32), Pointer<Utf8> Function(int)>(
'strerror',
isLeaf: true);
void main() {
for (var i = 0; i < 10000; i++) strerror(0).toDartString();
}