From bb104f07fcd4d379b003782264bfae327e034418 Mon Sep 17 00:00:00 2001 From: Emmanuel Pellereau Date: Thu, 23 Jun 2022 09:25:00 +0000 Subject: [PATCH] Revert "Reland "[vm] Remove warnings about non-standard stack traces."" This reverts commit 6651c297795ce8707bdb4d43f7e247e386c05da2. Reason for revert: breaks google3 (b/236928633) Original change's description: > Reland "[vm] Remove warnings about non-standard stack traces." > > This is a reland of commit cc9d14d822222e27828318f5b13080c54a241479 > > TEST=vm/dart{,_2}/causal_stacks/async_throws_stack_lazy_non_symbolic_test > > Original change's description: > > [vm] Remove warnings about non-standard stack traces. > > > > The language team has clarified in > > https://github.com/dart-lang/language/issues/1212 that the content of > > stack traces is not specified in a way that is violated by either > > obfuscation or non-symbolic stack traces. Thus, we remove the warnings > > about supposedly standard-violating stack traces. > > > > TEST=No change in actual functionality, so tested manually. > > > > Bug: https://github.com/dart-lang/sdk/issues/43388 > > Change-Id: I2c7ac44cf2f9afafa85d902b2783e1173e727264 > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249185 > > Commit-Queue: Tess Strickland > > Reviewed-by: Daco Harkes > > Reviewed-by: Martin Kustermann > > Bug: https://github.com/dart-lang/sdk/issues/43388 > Change-Id: Ifa7915b4ba21cca592ed5645cd9ad6cda1575f12 > Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249192 > Commit-Queue: Tess Strickland > Reviewed-by: Martin Kustermann > Reviewed-by: Daco Harkes TBR=kustermann@google.com,dacoharkes@google.com,sstrickl@google.com Change-Id: I65f3d84caee3ec9ac30f0ce058104bb24ef6ea11 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: https://github.com/dart-lang/sdk/issues/43388 Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249580 Commit-Queue: Emmanuel Pellereau Reviewed-by: Martin Kustermann Reviewed-by: Emmanuel Pellereau --- .../tests/vm/dart/causal_stacks/utils.dart | 23 ++++++++----------- .../tests/vm/dart_2/causal_stacks/utils.dart | 23 ++++++++----------- runtime/vm/isolate.cc | 7 ++++++ runtime/vm/object.cc | 6 +++++ 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/runtime/tests/vm/dart/causal_stacks/utils.dart b/runtime/tests/vm/dart/causal_stacks/utils.dart index 4356953531c..2269e315779 100644 --- a/runtime/tests/vm/dart/causal_stacks/utils.dart +++ b/runtime/tests/vm/dart/causal_stacks/utils.dart @@ -205,26 +205,21 @@ Future assertStack(List expects, StackTrace stackTrace, // Use the DWARF stack decoder if we're running in --dwarf-stack-traces mode // and in precompiled mode (otherwise --dwarf-stack-traces has no effect). - bool usingDwarf = false; - if (debugInfoFilename != null) { - try { - final dwarf = Dwarf.fromFile(debugInfoFilename)!; - usingDwarf = true; - frames = await Stream.fromIterable(original) - .transform(DwarfStackTraceDecoder(dwarf)) - .where(_lineRE.hasMatch) - .toList(); - } on FileSystemException { - // We're not running in precompiled mode, so the file doesn't exist and - // we can continue normally. - } + final decodeTrace = frames.first.startsWith('Warning:'); + if (decodeTrace) { + Expect.isNotNull(debugInfoFilename); + final dwarf = Dwarf.fromFile(debugInfoFilename!)!; + frames = await Stream.fromIterable(original) + .transform(DwarfStackTraceDecoder(dwarf)) + .where(_lineRE.hasMatch) + .toList(); } void printFrameInformation() { print('RegExps for expected stack:'); expects.forEach((s) => print('"${s}"')); print(''); - if (usingDwarf) { + if (decodeTrace) { print('Non-symbolic actual stack:'); original.forEach(print); print(''); diff --git a/runtime/tests/vm/dart_2/causal_stacks/utils.dart b/runtime/tests/vm/dart_2/causal_stacks/utils.dart index ec673b517ef..d7c80d1b245 100644 --- a/runtime/tests/vm/dart_2/causal_stacks/utils.dart +++ b/runtime/tests/vm/dart_2/causal_stacks/utils.dart @@ -207,26 +207,21 @@ Future assertStack(List expects, StackTrace stackTrace, // Use the DWARF stack decoder if we're running in --dwarf-stack-traces mode // and in precompiled mode (otherwise --dwarf-stack-traces has no effect). - bool usingDwarf = false; - if (debugInfoFilename != null) { - try { - final dwarf = Dwarf.fromFile(debugInfoFilename); - usingDwarf = true; - frames = await Stream.fromIterable(original) - .transform(DwarfStackTraceDecoder(dwarf)) - .where(_lineRE.hasMatch) - .toList(); - } on FileSystemException { - // We're not running in precompiled mode, so the file doesn't exist and - // we can continue normally. - } + final decodeTrace = frames.first.startsWith('Warning:'); + if (decodeTrace) { + Expect.isNotNull(debugInfoFilename); + final dwarf = Dwarf.fromFile(debugInfoFilename); + frames = await Stream.fromIterable(original) + .transform(DwarfStackTraceDecoder(dwarf)) + .where(_lineRE.hasMatch) + .toList(); } void printFrameInformation() { print('RegExps for expected stack:'); expects.forEach((s) => print('"${s}"')); print(''); - if (usingDwarf) { + if (decodeTrace) { print('Non-symbolic actual stack:'); original.forEach(print); print(''); diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 84694a600ba..d20cf5468a6 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -1739,6 +1739,13 @@ Isolate::Isolate(IsolateGroup* isolate_group, // how the vm_tag (kEmbedderTagId) can be set, these tags need to // move to the OSThread structure. set_user_tag(UserTags::kDefaultUserTag); + + if (group()->obfuscate()) { + OS::PrintErr( + "Warning: This VM has been configured to obfuscate symbol information " + "which violates the Dart standard.\n" + " See dartbug.com/30524 for more information.\n"); + } } #undef REUSABLE_HANDLE_SCOPE_INIT diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 88143201c6b..47633fef274 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -25878,6 +25878,12 @@ const char* StackTrace::ToCString() const { isolate_instructions_image.instructions_relocated_address(); auto const vm_relocated_address = vm_instructions_image.instructions_relocated_address(); + // The Dart standard requires the output of StackTrace.toString to include + // all pending activations with precise source locations (i.e., to expand + // inlined frames and provide line and column numbers). + buffer.Printf( + "Warning: This VM has been configured to produce stack traces " + "that violate the Dart standard.\n"); // This prologue imitates Android's debuggerd to make it possible to paste // the stack trace into ndk-stack. buffer.Printf(