diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java index 206c8683f3095de874b75464e44a717f6112a76f..a7860653075d8897e8378464797924b158d3d477 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java @@ -414,13 +414,12 @@ public class RDeparse { s.element.setSourceSection(source.createSection(s.start, s.length)); } } - } catch (AccessDeniedException | FileAlreadyExistsException e) { + } catch (AccessDeniedException | FileAlreadyExistsException | IllegalArgumentException e) { + // do not report because these exceptions are legitimate fixupSourcesTextInternal(); - } catch (IOException e) { + } catch (Throwable e) { RInternalError.reportError(e); fixupSourcesTextInternal(); - } catch (NoSuchAlgorithmException e) { - throw RInternalError.shouldNotReachHere("SHA-256 is an unknown algorithm"); } } diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java index 97a9ef4253e4d9abf1eaeed1b6ceb4b7a5385367..020aa75d51754a41515cebf39c56c8dac206b3e7 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java @@ -45,6 +45,8 @@ import com.oracle.truffle.r.runtime.context.RContext; */ public final class RInternalError extends Error implements TruffleException { + private static final String FASTR_ERRORS_LOG = "fastr_errors.log"; + private static final long serialVersionUID = 80698622974155216L; private static boolean initializing = false; @@ -154,19 +156,24 @@ public final class RInternalError extends Error implements TruffleException { @TruffleBoundary public static void reportErrorAndConsoleLog(Throwable throwable, int contextId) { - reportError(throwable, contextId); + reportErrorDefault(throwable, contextId); + } + + @TruffleBoundary + public static void reportError(Throwable t) { + reportErrorDefault(t, 0); } @TruffleBoundary - public static void reportError(Throwable throwable) { - reportError(throwable, 0); + private static void reportErrorDefault(Throwable t, int contextId) { + String errMsg = t instanceof RInternalError && t.getMessage() != null && !t.getMessage().isEmpty() ? t.getMessage() : t.getClass().getSimpleName(); + reportError(errMsg, t, contextId); } - private static void reportError(Throwable throwable, int contextId) { + private static void reportError(String errMsg, Throwable throwable, int contextId) { try { Throwable t = throwable; if (FastROptions.PrintErrorStacktracesToFile.getBooleanValue() || FastROptions.PrintErrorStacktraces.getBooleanValue()) { - ByteArrayOutputStream out = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(out)); String verboseStackTrace; @@ -184,10 +191,15 @@ public final class RInternalError extends Error implements TruffleException { System.err.println(out.toString()); System.err.println(verboseStackTrace); } - String message = t instanceof RInternalError && t.getMessage() != null && !t.getMessage().isEmpty() ? t.getMessage() : "internal error: " + t.getClass().getSimpleName(); + + String message = "An internal error occurred: \"" + errMsg + "\"\nPlease report an issue at https://github.com/oracle/fastr including the commands"; + if (FastROptions.PrintErrorStacktracesToFile.getBooleanValue()) { + message += " and the error log file '" + getLogFileName(contextId) + "'."; + } else { + message += "."; + } if (FastROptions.PrintErrorStacktracesToFile.getBooleanValue()) { - String suffix = contextId == 0 ? "" : "-" + Integer.toString(contextId); - Path logfile = Utils.getLogPath("fastr_errors.log" + suffix); + Path logfile = Utils.getLogPath(getLogFileName(contextId)); try (BufferedWriter writer = Files.newBufferedWriter(logfile, StandardCharsets.UTF_8, StandardOpenOption.APPEND, StandardOpenOption.CREATE)) { writer.append(new Date().toString()).append('\n'); @@ -196,7 +208,7 @@ public final class RInternalError extends Error implements TruffleException { } catch (IOException e) { e.printStackTrace(); } - System.err.println(message + " (see fastr_errors.log" + suffix + ")"); + System.err.println(message); if (RContext.isEmbedded()) { RSuicide.rSuicide("FastR internal error"); } @@ -205,12 +217,18 @@ public final class RInternalError extends Error implements TruffleException { System.err.println(message); } } + } catch (ExitException | ThreadDeath t) { + throw t; } catch (Throwable t) { System.err.println("error while reporting internal error:"); t.printStackTrace(); } } + private static String getLogFileName(int contextId) { + return contextId == 0 ? FASTR_ERRORS_LOG : FASTR_ERRORS_LOG + "-" + Integer.toString(contextId); + } + @Override public Node getLocation() { return null; diff --git a/mx.fastr/mx_fastr_pkgs.py b/mx.fastr/mx_fastr_pkgs.py index f165d094756c9f532823c7a758576df356bb7724..064697ae4d4dcb06abad83fe09be12ee26c2369a 100644 --- a/mx.fastr/mx_fastr_pkgs.py +++ b/mx.fastr/mx_fastr_pkgs.py @@ -204,14 +204,13 @@ def pkgtest(args): fastr_libinstall, fastr_install_tmp = _create_libinstall('fastr', test_installed) gnur_libinstall, gnur_install_tmp = _create_libinstall('gnur', test_installed) + global verbose if "--quiet" in args: global quiet quiet = True if "-v" in args or "--verbose" in args: - global verbose verbose = 1 elif "-V" in args: - global verbose verbose = 2 install_args = list(args)