Chrome V8 KeyAccumulator Bug

Chrome V8 suffers from a bug in KeyAccumulator that can cause a crash.

MD5 | 9fee601d9a1d2470bc41cfa501ef0dbc

Chrome: V8: A bug with KeyAccumulator 

for (let i = 0; i < 10; i++) {
let [tmp] = [,], arr = [...Array(9063)];
for (let j = 0; j < 400; j++) {

Crash log:
Received signal 11 SEGV_MAPERR 30d96df00000

==== C stack trace ===============================

[end of stack trace]
Segmentation fault

What happens here is:

1. When rehashing a hash table, it stores the pointer to the new table into the old table (<a href="" title="" class="" rel="nofollow"></a>). The new table is directly used as the backing store of the result array of "Reflect.ownKeys(arr)".
2. The shift method invokes the MoveElements method which invokes the Heap::LeftTrimFixedArray method when "len > JSArray::kMaxCopyElements" is fulfilled (<a href="" title="" class="" rel="nofollow"></a>).
3. The Heap::LeftTrimFixedArray method cuts out the left 8 bytes (a pointer) of the backing store, and leaves a filter object (8 bytes) in there (<a href="" title="" class="" rel="nofollow"></a>). It seems this operation is performed based on the assumption that the pointer to the backing store is not held in other places. But the pointer to it was stored into the old table at 1.
4. So the filter object created at 3 is collected from the old table when a garbage collection triggered, since the size of the filter object is 8 bytes, it hits the assertion (<a href="" title="" class="" rel="nofollow"></a>).

Found by: lokihardt

Related Posts