When emit_op_new_array successfully allocates a new JSArray but fails to allocate the corresponding ArrayStorage for it, it falls back to the out-of-line stub call to constructArray, which constructs and entirely new JSArray/ArrayStorage pair. This leaves us with a JSArray hanging around on the stack or in a register that did not go through its own constructor, thus giving it uninitialized memory in the two fields that are checked in JSArray::visitChildren. The fix for this is to detect when we have successfully allocated a JSArray but failed to allocate its backing store and to write zeros into the correct places in the object prior to abandoning it.
Created attachment 138492 [details] Patch
Comment on attachment 138492 [details] Patch (1) Regression test, please. (2) A better fix is to allocate the backing store first. That way, no special branching, and no zombie JSArray. (3) Please re-verify that this inlining is still a performance win. It's a bit odd to have an optimization only in the slow JIT.
<rdar://problem/11309000>
Created attachment 138583 [details] Bencher results These are the benchmark results for ToT without the optimization (just a stub call like we used to do) compared to the optimization along with this particular fix. Looks like a small win. I think when we finish bug 79198 arrays will be in a much better state in general.
Created attachment 138605 [details] Patch
Comment on attachment 138605 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=138605&action=review Boy, those perf numbers are whisper-thin. Still, the fix is good, so let's take it. > Source/JavaScriptCore/jit/JITInlineMethods.h:490 > + // Allocate the backing store for the array. We allocate the storage first > + // because it could fail and we have to take the slow path, which would leave > + // behind a zombie JSArray with inconsistent state, potentially causing a GC crash. Hard to understand a comment about a potentially bad alternate version of the code. I would just say, "We allocate the backing store first to ensure that garbage collection doesn't happen during JSArray initialization".
Fixed in http://trac.webkit.org/changeset/115096.
Reopening to attach new patch.
Created attachment 141188 [details] Patch
(In reply to comment #8) > Reopening to attach new patch. I don't think this is the bug you meant to reopen.
Sorry. No, it wasn't