-
Notifications
You must be signed in to change notification settings - Fork 229
Prevent stack overflow when selecting mesh elements (Stop recursive ToString() on mesh handles) #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Aleph0x
wants to merge
8
commits into
Facepunch:master
from
Aleph0x:fix/mesh-handle-tostring-recursion
Closed
Prevent stack overflow when selecting mesh elements (Stop recursive ToString() on mesh handles) #145
Aleph0x
wants to merge
8
commits into
Facepunch:master
from
Aleph0x:fix/mesh-handle-tostring-recursion
Conversation
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
MeshFace.ToString() was interpolating {Handle}, which calls FaceHandle.ToString() / PrintMembers(...) and can recurse through half-edge refs. This caused InsufficientExecutionStackException when the inspector or TreeView.ScrollTo(...) formats selected faces, especially with trace logging. Switched ToString() to a stable identifier (HandleIndex) and guard the object name to prevent recursive stringification.
Prevents InsufficientExecutionStackException spam when selecting vertices with trace logging enabled
Contributor
|
I'd rather the handles just had a tostring for the index incase they get logged by someone |
Contributor
Author
I’ll shift the fix |
aylaylay
requested changes
Dec 27, 2025
Contributor
aylaylay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put these on single line
I kept ToString() to just the index so it stays a low-level identity string. Higher-level tools can add whatever labeling or context they need
c186164 to
365eb5a
Compare
Contributor
Author
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.
Selecting mesh elements (edges, faces, vertices) with trace logging enabled could flood the console and eventually crash with:
System.InsufficientExecutionStackException: Insufficient stack to continue executing the program safely.This fixes the cause by changing
ToString()on mesh selection wrapper types so they no longer invoke handleToString()implementations that recursively walk/traverse the half-edge mesh structure.The mesh selection wrapper types
MeshEdge,MeshFace, andMeshVertexwere formatting their underlying handle objects directly inside interpolated strings.MeshEdge.ToString()included{Handle}where Handle is a HalfEdgeHandleMeshFace.ToString()included{Handle}where Handle is a FaceHandleMeshVertex.ToString()included{Handle}where Handle is a VertexHandleInterpolating
{Handle}callsHandle.ToString().From the stacktraces, those handle ToString() implementations go through
PrintMembers(StringBuilder ...), typical of record style or debugger display helpers. Those routines then stringify connected handles. Half edges reference vertices, vertices reference half edges, and so on. So we end up with an unbounded call stack until the runtime throws InsufficientExecutionStackException or at least until Trace Logging is disabled in the scene editor.