TI: Crash [@ JSString::isStaticAtom()]

RESOLVED FIXED

Status

()

defect
--
critical
RESOLVED FIXED
8 years ago
8 years ago

People

(Reporter: decoder, Assigned: igor)

Tracking

(Blocks 1 bug, {crash, testcase})

Trunk
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: fixed-in-tracemonkey, crash signature)

Attachments

(2 attachments, 1 obsolete attachment)

Reporter

Description

8 years ago
The attached testcase crashes on TI revision 97f9e3274bd5 (run main.js with -j -m -a), tested on 64 bit.

Backtrace:

==12185== Invalid read of size 8
==12185==    at 0x46ED10: JSString::isStaticAtom() const (jsstr.h:367)
==12185==    by 0x4CCF38: js::gc::MarkId(JSTracer*, jsid) (jsgcmark.cpp:252)
==12185==    by 0x4CCFDA: js::gc::MarkId(JSTracer*, jsid, char const*) (jsgcmark.cpp:263)
==12185==    by 0x4CE33F: js::gc::MarkChildren(JSTracer*, js::Shape const*) (jsgcmark.cpp:653)
==12185==    by 0x4CE62C: JS_TraceChildren (jsgcmark.cpp:719)
==12185==    by 0x42D8E5: JS_DumpHeap (jsapi.cpp:2554)
==12185==    by 0x40C21D: DumpHeap(JSContext*, unsigned int, jsval_layout*) (js.cpp:2730)
==12185==    by 0x4F342D: js::CallJSNative(JSContext*, int (*)(JSContext*, unsigned int, js::Value*), unsigned int, js::Value*) (jscntxtinlines.h:293)
==12185==    by 0x716966: CallCompiler::generateNativeStub() (MonoIC.cpp:839)
==12185==    by 0x7114FE: js::mjit::ic::NativeCall(js::VMFrame&, js::mjit::ic::CallICInfo*) (MonoIC.cpp:1108)
==12185==    by 0x41B3F82: ???
==12185==    by 0x691BC0: js::mjit::EnterMethodJIT(JSContext*, js::StackFrame*, void*, js::Value*) (MethodJIT.cpp:882)
==12185==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==12185== 
==12185== 
==12185== Process terminating with default action of signal 11 (SIGSEGV)
TM bug, JS_DumpHeap calls TraceRuntime which invokes the conservative GC without first purging the compartment's freelists.  This causes the conservative GC to think an object is live when it has not been allocated yet, and we crash.

This is I think a regression from bug 601234.  Igor, do you mind looking at this?
Blocks: 601234
No longer blocks: infer-regress
That sounds vaguely like Bug 652985, though that was before bug 601234, so it couldn't have been caused by that.
Assignee

Updated

8 years ago
Assignee: general → igor
Assignee

Comment 3

8 years ago
Posted patch v1 (obsolete) — Splinter Review
The patch adds a helper class that temporary copies the free list to the arena and then clears the arenas again in the destructor. Its instance in TraceRuntime ensures that the conservative scanner can safely access the free list when dumping the arenas.

Another fix is the call to gcHelperThread.waitBackgroundSweepEnd before tracing the heap. Without that the conservative scanner may access just finalized things.
Attachment #533853 - Flags: review?(wmccloskey)
Assignee

Comment 4

8 years ago
Posted patch v2Splinter Review
Here is an update in view of bug 658137 landing. The new patch uses AutoCopyFreeListToArenas in IterateCells to remove the free list checks in IterateArenaCells. 

IterateCells also has a bug with missing RecordNativeStackTopForGC. This is important if AutoSession would wait for another GC to finish. To make sure that this would not happen in future I have added the call to LetOtherGCFinish where it should have been put long time ago.
Attachment #533853 - Attachment is obsolete: true
Attachment #533853 - Flags: review?(wmccloskey)
Attachment #534004 - Flags: review?(wmccloskey)
Comment on attachment 534004 [details] [diff] [review]
v2

Review of attachment 534004 [details] [diff] [review]:
-----------------------------------------------------------------

Now I understand the reason for RecordNativeStackTopForGC. Thanks.

::: js/src/jsgc.cpp
@@ -2717,5 @@
> -    /* -16k because it is possible to perform a GC during an overrecursion report. */
> -    JS_ASSERT_IF(cx->stackLimit, JS_CHECK_STACK_SIZE(cx->stackLimit - (1 << 14), &stackDummy));
> -# endif
> -#endif
> -

I'm glad to see this go.

::: js/src/jsgc.h
@@ +750,5 @@
> +        }
> +    }
> +
> +    /*
> +     * Copy temporary the free list heads to the arenas so the code can see

"Temporarily copy"

@@ +764,5 @@
> +        }
> +    }
> +
> +    /*
> +     * Clear the free lists in arenas that were temporary set there using

"temporarily"
Comment on attachment 534004 [details] [diff] [review]
v2

Review of attachment 534004 [details] [diff] [review]:
-----------------------------------------------------------------

Now I understand the reason for RecordNativeStackTopForGC. Thanks.

::: js/src/jsgc.cpp
@@ -2717,5 @@
> -    /* -16k because it is possible to perform a GC during an overrecursion report. */
> -    JS_ASSERT_IF(cx->stackLimit, JS_CHECK_STACK_SIZE(cx->stackLimit - (1 << 14), &stackDummy));
> -# endif
> -#endif
> -

I'm glad to see this go.

::: js/src/jsgc.h
@@ +750,5 @@
> +        }
> +    }
> +
> +    /*
> +     * Copy temporary the free list heads to the arenas so the code can see

"Temporarily copy"

@@ +764,5 @@
> +        }
> +    }
> +
> +    /*
> +     * Clear the free lists in arenas that were temporary set there using

"temporarily"
Attachment #534004 - Flags: review?(wmccloskey) → review+
Assignee

Comment 7

8 years ago
http://hg.mozilla.org/tracemonkey/rev/0e2d15573f6c
Whiteboard: fixed-in-tracemonkey
Assignee

Comment 8

8 years ago
Christian: could you test that the landed patch fixes the test case? I cannot reproduce it on my box even if the problem from the comment 1 is real.
It looks like non-THREADSAFE builds are burning, TraceRuntime uses 'rt' without defining it first.
Assignee

Comment 10

8 years ago
http://hg.mozilla.org/tracemonkey/rev/57412df720cf - followup to fix !JS_THREADSAFE builds.
Reporter

Comment 11

8 years ago
Igor: The original test  in comment 1 is for the JM branch. So to verify this fix, I need the changes pushed on the JM branch as well. It's likely that the test will not repro on TM at all, even if the underlying problem is in TM.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Reporter

Comment 13

8 years ago
I retested this on TI tip and it does no longer reproduce now :)
Assignee

Comment 14

8 years ago
(In reply to comment #13)
> I retested this on TI tip and it does no longer reproduce now :)

Thanks!
Crash Signature: [@ JSString::isStaticAtom()]
Reporter

Updated

8 years ago
Blocks: 676763
You need to log in before you can comment on or make changes to this bug.