Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Request bug report if fletch crashes
Browse files Browse the repository at this point in the history
Fixes #87

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org/1345213002 .
  • Loading branch information
peter-ahe-google committed Sep 18, 2015
1 parent cee917f commit aa2c3c4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/fletchc/lib/src/driver/driver_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ import 'session_manager.dart' show
import '../verbs/create_verb.dart' show
CreateSessionTask;

import '../please_report_crash.dart' show
crashReportRequested,
requestBugReportOnOtherCrashMessage;

Function gracefulShutdown;

class DriverCommandTransformerBuilder
Expand Down Expand Up @@ -235,6 +239,7 @@ Future<Null> handleVerb(
List<String> arguments,
ClientController client,
IsolatePool pool) async {
crashReportRequested = false;

Future<int> performVerb() async {
client.parseArguments(arguments);
Expand All @@ -261,6 +266,10 @@ Future<Null> handleVerb(
handleLateError: client.log.error)
.catchError(client.reportErrorToClient, test: (e) => e is InputError)
.catchError((error, StackTrace stackTrace) {
if (!crashReportRequested) {
client.printLineOnStderr(requestBugReportOnOtherCrashMessage);
crashReportRequested = true;
}
client.printLineOnStderr('$error');
if (stackTrace != null) {
client.printLineOnStderr('$stackTrace');
Expand Down Expand Up @@ -416,6 +425,10 @@ class ClientController {
}

int reportErrorToClient(InputError error, StackTrace stackTrace) {
if (!crashReportRequested) {
printLineOnStderr(requestBugReportOnOtherCrashMessage);
crashReportRequested = true;
}
printLineOnStderr(error.asDiagnostic().formatMessage());
if (error.kind == DiagnosticKind.internalError) {
printLineOnStderr('$stackTrace');
Expand Down Expand Up @@ -447,6 +460,8 @@ class IsolateController {
/// Subscription for errors from [isolate].
StreamSubscription errorSubscription;

bool crashReportRequested = false;

IsolateController(this.isolate);

/// Begin a session with the worker isolate.
Expand Down Expand Up @@ -474,9 +489,14 @@ class IsolateController {
/// isolate sends DriverCommand.ClosePort, or if the isolate is killed due to
/// DriverCommand.Signal arriving through client.commands.
Future<Null> attachClient(ClientController client) async {
crashReportRequested = false;
errorSubscription.onData((errorList) {
String error = errorList[0];
String stackTrace = errorList[1];
if (!crashReportRequested) {
client.printLineOnStderr(requestBugReportOnOtherCrashMessage);
crashReportRequested = true;
}
client.printLineOnStderr(error);
if (stackTrace != null) {
client.printLineOnStderr(stackTrace);
Expand Down
9 changes: 9 additions & 0 deletions pkg/fletchc/lib/src/fletch_compiler_implementation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ import 'package:compiler/src/util/util.dart' show
import 'fletch_registry.dart' show
FletchRegistry;

import 'please_report_crash.dart' show
crashReportRequested,
requestBugReportOnCompilerCrashMessage;

import 'fletch_function_builder.dart';
import 'debug_info.dart';
import 'find_position_visitor.dart';
Expand Down Expand Up @@ -275,6 +279,11 @@ class FletchCompilerImplementation extends apiimpl.Compiler {
}
}

void pleaseReportCrash() {
crashReportRequested = true;
print(requestBugReportOnCompilerCrashMessage);
}

void reportError(
Spannable node,
MessageKind messageKind,
Expand Down
40 changes: 40 additions & 0 deletions pkg/fletchc/lib/src/please_report_crash.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2015, the Fletch 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.md file.

library fletchc.please_report_crash;

bool crashReportRequested = false;

// TODO(ahe): Include build ID.
const String requestBugReportOnCompilerCrashMessage = """
The Fletch compiler is broken.
When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.
The Fletch team would greatly appreciate if you would take a moment to
report this problem at https://github.com/dart-lang/fletch/issues/new
Please include the following information:
* the name and version of your operating system
* the entire message you see here (including the full stack trace
below as well as the source location above)
""";

// TODO(ahe): Include build ID.
const String requestBugReportOnOtherCrashMessage = """
The Fletch program is broken and has crashed.
The Fletch team would greatly appreciate if you would take a moment to
report this problem at https://github.com/dart-lang/fletch/issues/new
Please include the following information:
* the name and version of your operating system
* the entire message you see here (including the full stack trace below)
""";

0 comments on commit aa2c3c4

Please sign in to comment.