From 84d7826ab9d9bf2dade04dcc72d857b4db83087d Mon Sep 17 00:00:00 2001 From: David Mandelin Date: Tue, 26 Oct 2010 19:02:01 -0700 Subject: [PATCH] Bug 604756 diagnostic: serialize flatten to test if concurrent calls cause the bug, r=dvander, a=beta 7 blocker --- js/src/jsstr.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 925bf319fe6b..b3beae68ffdb 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -104,6 +104,18 @@ js_GetStringChars(JSContext *cx, JSString *str) void JSString::flatten() { + // Diagnostic: serialize all calls to this function to see + // if concurrent calls are crashing us. + JS_LOCK_RUNTIME(asCell()->compartment()->rt); + // The main body of this function can be executed only if + // the string is a rope. With multiple threads, it's possible + // we waited while another one ran, and the string has + // already been flattened for us. + if (!isRope()) { + JS_UNLOCK_RUNTIME(asCell()->compartment()->rt); + return; + } + JSString *topNode; jschar *chars; size_t capacity; @@ -181,6 +193,8 @@ JSString::flatten() /* Set null terminator. */ chars[pos] = 0; topNode->initFlatMutable(chars, pos, capacity); + + JS_UNLOCK_RUNTIME(asCell()->compartment()->rt); } #ifdef JS_TRACER