Bug 1367896: Include script filename in crash reason. r=shu data-r=bsmedberg a=jcristau
authorKris Maglione <maglione.k@gmail.com>
Wed, 05 Jul 2017 18:02:20 -0700
changeset 411910 7d7f50458f9c9bf1d577ff158fc3e59fd4e38b34
parent 411909 ba0b7a246e875f94fd2d1a54436fe1711480dc0b
child 411911 ce3be5cd53c8b65670c5f8620adbfd011dd3a286
push id7500
push usercbook@mozilla.com
push dateWed, 12 Jul 2017 13:27:26 +0000
treeherdermozilla-beta@2f1f99506678 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu, jcristau
bugs1367896
milestone55.0
Bug 1367896: Include script filename in crash reason. r=shu data-r=bsmedberg a=jcristau If the scope that we're trying to clone is actually a function script, this should give us the script URL. If it's not (presumably due to some sort of data corruption), it should give us a different crash, which should hopefully give us more information. MozReview-Commit-ID: Fppi0qt4GJP
js/src/vm/Scope.cpp
--- a/js/src/vm/Scope.cpp
+++ b/js/src/vm/Scope.cpp
@@ -367,19 +367,27 @@ Scope::clone(JSContext* cx, HandleScope 
     RootedShape envShape(cx);
     if (scope->environmentShape()) {
         envShape = scope->maybeCloneEnvironmentShape(cx);
         if (!envShape)
             return nullptr;
     }
 
     switch (scope->kind_) {
-      case ScopeKind::Function:
+      case ScopeKind::Function: {
+        RootedScript script(cx, scope->as<FunctionScope>().script());
+        const char* filename = script->filename();
+        // If the script has an internal URL, include it in the crash reason. If
+        // not, it may be a web URL, and therefore privacy-sensitive.
+        if (!strncmp(filename, "chrome:", 7) || !strncmp(filename, "resource:", 9))
+            MOZ_CRASH_UNSAFE_PRINTF("Use FunctionScope::clone (script URL: %s)", filename);
+
         MOZ_CRASH("Use FunctionScope::clone.");
         break;
+      }
 
       case ScopeKind::FunctionBodyVar:
       case ScopeKind::ParameterExpressionVar: {
         Rooted<VarScope::Data*> original(cx, &scope->as<VarScope>().data());
         UniquePtr<VarScope::Data> dataClone = CopyScopeData<VarScope>(cx, original);
         if (!dataClone)
             return nullptr;
         return create(cx, scope->kind_, enclosing, envShape, Move(dataClone));