Fix Array and CanvasMapper crashes - #65
Open
atkurtul wants to merge 4 commits into
Open
Conversation
CanvasMapper took the Input array's data view, cast it to a flatbuffers vector and called size() on it. Ok() returns null when the pin holds no object, and the view it would have returned belongs to a temporary whose guard reference dies with the statement, so feeding the node from an Array node crashed it. Read every layer field through the object API instead. The loop also stops at the 16 layers the shader declares, indexes the blend mode bits by the packed draw position rather than the source position so a skipped layer no longer shifts them, and keeps each layer texture referenced until the pass is submitted.
Four faults, all reachable from the editor. Removing an element whose name did not parse indexed the input vector with SIZE_MAX. The remove menu command dereferenced GetPin without checking it found anything. ExecuteNode dereferenced a pin's object pointer unconditionally. And both edit paths copied the array into the storage of the ObjectRef that already held the old array, overwriting the reference without releasing it, so every add and remove leaked one. Bounds check the index, check the pin, fail the execution rather than silently emitting a shorter array, and route both edits through ApplyArrayDelta, which writes to a fresh reference and moves it in so the previous one is released. Element pins are matched by name because they can be shown as properties and are still executed.
The SDK already interprets an object's data view for a trivially copyable type, so the manual buffer handling was a reimplementation.
Drops the local helper now that the SDK reads a trivially copyable field in one call.
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.
Two crashes reachable by wiring an Array node into a CanvasMapper, plus the faults found while reading around them.
Read canvas layers through the object API
CanvasMappertook theInputarray's data view, cast it to aflatbuffers::Vectorand calledsize()on it.Ok()returns null when the pin holds no object, and the view it would otherwise return belongs to a temporary whose guard reference dies with the statement — so the pointer dangled even when it was non-null.Every layer field now goes through the object API. Also in that loop:
ObjectRefthat died at the end of the iteration;Harden the Array node
Four independent faults, all reachable from the editor:
SIZE_MAXfrom a failed name parse used as an indexGetPin(itemId)->DisplayNameunchecked*pin->ObjectuncheckedCopyArrayObjectWithEdits(..., &ArrayObject.GetStorage())The leak is the subtle one: writing the new id into the storage of a live
ObjectRefoverwrites the reference it holds without releasing it. Both edit paths now go throughApplyArrayDelta, which writes to a fresh reference and moves it in, so move-assignment releases the previous one.Element pins are matched by name rather than by
ShowAs. They carryCanShowAs::INPUT_PIN_OR_PROPERTYand are still executed when shown as properties, so filtering onShowAswould silently drop them.Notes
GetInputs()stops at the first gap inInput N, so removing a middle element leaves a pin the node cannot see while execution still counts it. It no longer crashes, but the UI count and the array length disagree. Fixing it means choosing between renumbering the survivors and restricting removal to the last element.