Repository navigation
Conversation
TraverseGraph re-queued a block whenever its incoming depth merely differed from the recorded one, and overwrote the recorded value outright. That is not a monotone dataflow, so it is not guaranteed to converge: when a join has predecessors that disagree on the depth, each visit flips the block between the two values, and when a loop raises the depth once per iteration it climbs forever. It stays hidden on code where every join agrees, which is why it can survive a long time. It shows up on a Unity 2018.2.14 Windows x64 build (metadata version 24): 1,969 methods and still climbing hit the 500,000-block backstop, each one burning the entire budget, and the run had to be abandoned. Raise-only propagation converges, and cannot change a well-formed method because a block's depth is unique there. A depth that would drop is kept at the larger value and the method is flagged, and a 512-byte ceiling bounds pathological growth, so neither case passes silently. Before: 1,969+ methods lost to 'Stack state not settling', run never finished. After: 0 such methods, run completes in 268s, 64 assemblies emitted, zero analysis exceptions. On a second, unrelated build (Android ARM64, metadata 24.5) the compiled output is unchanged.
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.
The problem
StackAnalyzer.TraverseGraphre-queues a block whenever its incoming depth merely differs from the recorded one, while overwriting the recorded value outright:That is not a monotone dataflow, so it is not guaranteed to converge:
MaxBlockVisitCount = 500000only converts the hang into "one exception per method", and each victim still burns the whole 500,000-block budget.Where it shows up
A Unity 2018.2.14 Windows x64 IL2CPP build (metadata version 24):
1,969 methods and still climbing, with the log at 216,656 lines and the run never finishing (>20 min, killed). The same binary handles an Android ARM64 build (metadata 24.5) fine, because there every join happens to agree - which is presumably why this has gone unnoticed.
The fix
Propagate monotonically: only ever raise a block's incoming depth.
AddWarning) so it is not silent.Results
Stack state not settlingmethodsOn the unrelated Android ARM64 build the emitted output is unchanged (verified by compiling all 23 game assemblies and comparing the error count, which stayed at 418, assembly for assembly).
One caveat worth stating plainly: this eliminates the hang, not the underlying disagreement. If two predecessors really do disagree about the depth, the method now proceeds with the deeper value rather than looping or being skipped, and says so through
AddWarning.