On Tue Feb 17 15:26:06 2026 +0000, Gabriel Ivăncescu wrote:
J doesn't have to be a root, it has to be "reachable" from a root (i.e. it traverses from the root and marks them somehow, rest of JS objects are marked gray). But let's focus where J is not reachable from any root. Even if J is not reachable from any root and the GC consequently marks it as gray, B can't be collected because A isn't. In other words, J is basically a "wrapped" XPCOM object that: 1) is treated as having no external refs to it *if* it is marked Gray. 2) is treated as having external refs otherwise. But now in your example it's not J that keeps it alive (because it has no external refs), it's A, because A has external refs to it, and reaches to B via J. Does that make sense? Let me know if I need to expand on it. I do not see how that explains things. Let’s modify the example so that A becomes A1 -> A2 -> ... -> A1000 -> J1 -> J2 -> ... -> J1000 -> B, and only A1 has an external reference. Only CC knows the relationship between A1 and A1000, so only it knows about those references. According to your description, only GC knows the relationship between J1 and J1000. That means that “A reaches B via J” is not something either of them can determine on its own.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/10045#note_130990