Repository navigation
Conversation
TraverseGCDescriptor's diagnostic fires when a traversed value looks corrupt, and then dereferences that value's class pointer - first via HasParentUnsafe, then via logAll. When the class pointer really is bad, that turns the report into a SIGSEGV on the AssetGarbageCollector thread, so the crash it warns about is the crash it causes. The log ends at "Attempting HasParentUnsafe(...)" with nothing after it. Seen on Beat Saber 1.40.8 (custom-types 0.18.4): 18 of 40 crashes in one user's tombstones were this, faulting at 0xfffffffffffffff8 - the address you get from klass->typeHierarchy[parent->typeHierarchyDepth - 1] when typeHierarchy is NULL and the depth byte reads 0. The game's own code tolerates the same values; only this diagnostic dies on them. Check both class pointers before dereferencing them, and log which one looked wrong when we skip. Everything that was already safe to dump - the warning, the offending instance, its class and gc_desc, the field index, the value, the traverse counters, the class dump of obj - is unchanged, so the diagnostic still reports what it was written to report. Note the filter class is read from state+0x10; on this build the LivenessState constructor stores the filter at +0x08 (+0x10 is process_array), so filterClass is usually not a class at all. This change deliberately does not touch that offset - it just stops a wrong value being fatal. 0.20.1 resolves the offset properly in liveness.cpp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same fix as PR #27, against the 0.18.x line.
This is the branch that matters for impact:
version/v0_18_4is the last beatsaber-hook 6.x release, which makes it the only line that runs on Beat Saber 1.40.8 — where this crash is actually hitting users today. The 0.18.5+ and 0.19.x lines moved to beatsaber-hook 7, and 0.20.x to 8, so none of them are installable there.Unlike the
masterchange, this one is build-verified and tested on hardware.The bug
TraverseGCDescriptor's diagnostic fires when a traversed value looks corrupt, then dereferences that value's class pointer — viaHasParentUnsafe, which readsklass->typeHierarchyDepthand indexesklass->typeHierarchy, and vialogAll. Neither is guarded beyond a null check.When the class pointer really is bad — the case the diagnostic exists to report — the report becomes a SIGSEGV on the
AssetGarbageCollectorthread. The log ends atAttempting HasParentUnsafe(...)with nothing after it, so the warning that says "THIS WILL CRASH" is itself the crash.In one user's tombstones from Beat Saber 1.40.8, 18 of 40 crashes were this signature — the single most common cause, ahead of an unrelated beatsaber-hook issue at 16. Every one faulted at
0x00fffffffffffff8, which is exactlywith
typeHierarchy == NULLand a depth byte of0, i.e.*(NULL - 8).The game's own code tolerates these same values — disassembling the corresponding game path shows it reads a flag byte and skips. This diagnostic converts a condition the game handles safely into a hard crash.
The change
Add
LooksLikeValidClass()— a realIl2CppClasspoints itsklassfield back at itself and has a name — and check both class pointers before dereferencing, logging which one looked wrong when skipping.Everything already safe to dump is unchanged: the warning, the offending instance, its class and
gc_desc, the field index, the value pointer, the traverse counters, and thelogAllofobj.Before (stock 0.18.4 — log ends here, process gone):
After (same input, same repro):
Testing
Built against this branch (NDK 27, beatsaber-hook 6.x) and installed on a Quest 2 running Beat Saber 1.40.8. The condition is reproduced in memory by a test mod that builds a
PlayerLevelStatsDatawhose_levelIDpoints at an invalid object, then callsResources.UnloadUnusedAssets()— no gameplay needed, and it never touches the save file.No new tombstones across the patched runs, and the field index the dump reports (
idx: 5,_levelID) matches the original user's crashes.Happy to share the repro mod, and a PC-only harness that replays the hook against the real
Il2CppClasslayout underqemu-aarch64and reproduces the same fault address without a headset.Not addressed
PlayerLevelStatsData._levelIDwhile the record stays live; that cause is still unknown. This only stops the reporting path being fatal.state + 0x10, and on 1.40.8 theLivenessStateconstructor stores it at+0x08(+0x10isprocess_array), sofilterClassis usually not a class at all. Deliberately untouched here — the guard makes a wrong filter non-fatal without asserting what the right one is, andmasteralready resolves this properly inliveness.cpp.