[ VM ] Exit with error if --disable-dart-dev is provided after a Dart CLI command
Fixes https://github.com/dart-lang/sdk/issues/56592
Fixed: 56592
TEST=regress_56592_test.dart
Change-Id: I3363a27c6a4221a3c5388b3472cee978649c1e39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382700
Commit-Queue: Derek Xu <derekx@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
diff --git a/pkg/dartdev/test/regress_56592_test.dart b/pkg/dartdev/test/regress_56592_test.dart
new file mode 100644
index 0000000..42ae54d
--- /dev/null
+++ b/pkg/dartdev/test/regress_56592_test.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2024, 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.
+
+import 'dart:io';
+
+import 'package:expect/expect.dart';
+
+// Passing --disable-dart-dev after a DartDev command should cause the VM to
+// exit with an error, not cause a segfault.
+//
+// See https://github.com/dart-lang/sdk/issues/56592 for details.
+
+Future<void> main() async {
+ final result = await Process.run(
+ Platform.resolvedExecutable,
+ [
+ 'test',
+ '--disable-dart-dev',
+ ],
+ );
+ Expect.contains(
+ 'Attempted to use --disable-dart-dev with a Dart CLI command.',
+ result.stderr,
+ );
+}
diff --git a/runtime/bin/main_options.cc b/runtime/bin/main_options.cc
index 99d9207..9c60482 100644
--- a/runtime/bin/main_options.cc
+++ b/runtime/bin/main_options.cc
@@ -719,6 +719,13 @@
OptionProcessor::TryProcess(argv[tmp_i], vm_options);
tmp_i++;
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ if (Options::disable_dart_dev()) {
+ Syslog::PrintErr(
+ "Attempted to use --disable-dart-dev with a Dart CLI command.\n");
+ Platform::Exit(kErrorExitCode);
+ }
+#endif // !defined(DART_PRECOMIPLED_RUNTIME)
}
bool first_option = true;
// Parse out options to be passed to dart main.