[runtime] sort transition array after it grows beyond linear search size [v8/v8 : main]

0 views
Skip to first unread message

Joyee Cheung (Gerrit)

unread,
Dec 12, 2025, 4:15:59 AM (4 days ago) Dec 12
to Igor Sheludko, Leszek Swirski, Michaël Zasso, V8 LUCI CQ, v8-re...@googlegroups.com
Attention needed from Igor Sheludko

Joyee Cheung added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Joyee Cheung . resolved

PTAL, thanks, we found this during the V8 update in Node.js

Open in Gerrit

Related details

Attention is currently required from:
  • Igor Sheludko
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I3f45816b7d65bbbcfedeb7074d0c6907cbc08edf
Gerrit-Change-Number: 7252791
Gerrit-PatchSet: 1
Gerrit-Owner: Joyee Cheung <jo...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Joyee Cheung <jo...@igalia.com>
Gerrit-CC: Leszek Swirski <les...@chromium.org>
Gerrit-CC: Michaël Zasso <mic.b...@gmail.com>
Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
Gerrit-Comment-Date: Fri, 12 Dec 2025 09:15:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Igor Sheludko (Gerrit)

unread,
Dec 12, 2025, 5:06:06 AM (4 days ago) Dec 12
to Joyee Cheung, Leszek Swirski, Michaël Zasso, V8 LUCI CQ, v8-re...@googlegroups.com
Attention needed from Joyee Cheung

Igor Sheludko added 1 comment

Patchset-level comments
File-level comment, Patchset 2 (Latest):
Igor Sheludko . resolved

Thanks for fixing this!
looks good, but could you please create a regression test for this issue?

Open in Gerrit

Related details

Attention is currently required from:
  • Joyee Cheung
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: v8/v8
Gerrit-Branch: main
Gerrit-Change-Id: I3f45816b7d65bbbcfedeb7074d0c6907cbc08edf
Gerrit-Change-Number: 7252791
Gerrit-PatchSet: 2
Gerrit-Owner: Joyee Cheung <jo...@igalia.com>
Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
Gerrit-Reviewer: Joyee Cheung <jo...@igalia.com>
Gerrit-CC: Leszek Swirski <les...@chromium.org>
Gerrit-CC: Michaël Zasso <mic.b...@gmail.com>
Gerrit-Attention: Joyee Cheung <jo...@igalia.com>
Gerrit-Comment-Date: Fri, 12 Dec 2025 10:06:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
open
diffy

Igor Sheludko (Gerrit)

unread,
Dec 12, 2025, 5:08:25 AM (4 days ago) Dec 12
to Joyee Cheung, Leszek Swirski, Michaël Zasso, V8 LUCI CQ, v8-re...@googlegroups.com
Attention needed from Joyee Cheung

Igor Sheludko added 1 comment

File src/objects/transitions.cc
Line 181, Patchset 2 (Latest): SLOW_DCHECK(array->IsSortedNoDuplicates());
Igor Sheludko . unresolved

BTW, do these checks catch the issue?

Open in Gerrit

Related details

Attention is currently required from:
  • Joyee Cheung
Submit Requirements:
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: v8/v8
    Gerrit-Branch: main
    Gerrit-Change-Id: I3f45816b7d65bbbcfedeb7074d0c6907cbc08edf
    Gerrit-Change-Number: 7252791
    Gerrit-PatchSet: 2
    Gerrit-Owner: Joyee Cheung <jo...@igalia.com>
    Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
    Gerrit-Reviewer: Joyee Cheung <jo...@igalia.com>
    Gerrit-CC: Leszek Swirski <les...@chromium.org>
    Gerrit-CC: Michaël Zasso <mic.b...@gmail.com>
    Gerrit-Attention: Joyee Cheung <jo...@igalia.com>
    Gerrit-Comment-Date: Fri, 12 Dec 2025 10:08:20 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Joyee Cheung (Gerrit)

    unread,
    Dec 12, 2025, 11:41:24 AM (4 days ago) Dec 12
    to Igor Sheludko, Leszek Swirski, Michaël Zasso, V8 LUCI CQ, v8-re...@googlegroups.com
    Attention needed from Igor Sheludko

    Joyee Cheung added 2 comments

    Patchset-level comments
    Igor Sheludko . resolved

    Thanks for fixing this!
    looks good, but could you please create a regression test for this issue?

    Joyee Cheung

    I tried to add a test, but it doesn't seem to be crashing without the patch. From what I can tell from the Node.js reproduction, it involves one special transition (with the frozen symbol), though it's a bit tricky to track down what was inserted in that reproduction which is fairly huge. I'll try to see if I can trace what exactly was inserted in that faulting object and in what order..

    File src/objects/transitions.cc
    Line 181, Patchset 2: SLOW_DCHECK(array->IsSortedNoDuplicates());
    Igor Sheludko . resolved

    BTW, do these checks catch the issue?

    Joyee Cheung

    From testing the Node.js built, the check caught it when there were duplicates, and the fix here was enough for me to turn these two into DCHECK and still pass the entire Node.js test suite.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Igor Sheludko
    Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I3f45816b7d65bbbcfedeb7074d0c6907cbc08edf
      Gerrit-Change-Number: 7252791
      Gerrit-PatchSet: 3
      Gerrit-Owner: Joyee Cheung <jo...@igalia.com>
      Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
      Gerrit-Reviewer: Joyee Cheung <jo...@igalia.com>
      Gerrit-CC: Leszek Swirski <les...@chromium.org>
      Gerrit-CC: Michaël Zasso <mic.b...@gmail.com>
      Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
      Gerrit-Comment-Date: Fri, 12 Dec 2025 16:41:19 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Igor Sheludko <ish...@chromium.org>
      unsatisfied_requirement
      open
      diffy

      Joyee Cheung (Gerrit)

      unread,
      Dec 15, 2025, 11:15:33 AM (21 hours ago) Dec 15
      to Igor Sheludko, Leszek Swirski, Michaël Zasso, V8 LUCI CQ, v8-re...@googlegroups.com
      Attention needed from Igor Sheludko and Joyee Cheung

      Joyee Cheung voted and added 1 comment

      Votes added by Joyee Cheung

      Commit-Queue+1

      1 comment

      Patchset-level comments
      File-level comment, Patchset 5 (Latest):
      Joyee Cheung . resolved

      I looked into the reproduction a bit more and worked out a reproducing test. It basically goes like this:

      1. During snapshot creation, Node.js grows the transitions of the cached map
      2. After a round of snapshot serialization/deserialization, the transitions gets rehashed, so it's "shuffled" in terms of ordering based on the hash (in this case, it's an array of size 27)
      3. TransitionAccessor:InsertHelper() assumes that the array is always sorted even if it's below the kMaxElementsForLinearSearch, and after rehashing that assumption gets broken. So once the insertion grows the size to 32 that broken assumption start to show.

      Another fix might be to update `HeapObject::RehashBasedOnMap` so that it always sort the transition arrays even if their size is below the linear search size, though I feel that the current fix still seems more robust as it seems a bit shaky to assume the array must always be sorted even when it's below kMaxElementsForLinearSearch, and maintaining the sorting regardless of size also defeats the purpose of having this threshold.

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Igor Sheludko
      • Joyee Cheung
      Submit Requirements:
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: v8/v8
      Gerrit-Branch: main
      Gerrit-Change-Id: I3f45816b7d65bbbcfedeb7074d0c6907cbc08edf
      Gerrit-Change-Number: 7252791
      Gerrit-PatchSet: 5
      Gerrit-Owner: Joyee Cheung <jo...@igalia.com>
      Gerrit-Reviewer: Igor Sheludko <ish...@chromium.org>
      Gerrit-Reviewer: Joyee Cheung <jo...@igalia.com>
      Gerrit-CC: Leszek Swirski <les...@chromium.org>
      Gerrit-CC: Michaël Zasso <mic.b...@gmail.com>
      Gerrit-Attention: Igor Sheludko <ish...@chromium.org>
      Gerrit-Attention: Joyee Cheung <jo...@igalia.com>
      Gerrit-Comment-Date: Mon, 15 Dec 2025 16:15:29 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      unsatisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages