mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:43:57 +00:00
bd4a27ff81
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>
23 lines
781 B
Dart
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();
|
|
}
|