Inochi2D/inochi-creator

[BUG] Application crashed when removing Part object which is used as a mask of other Part.

Closed this issue · 3 comments

Validations

  • I have checked for similar bug reports and could not find any.
  • I have tested and confirmed that this is an issue in an official branded build.

Describe the bug

When condition of title is met, application crashed with following crash dump.

hread 1 "inochi-creator" received signal SIGSEGV, Segmentation fault.
0x0000555555bd9c85 in _D8inochi2d4math9transform9Transform6matrixMFZS6inmath6linalg__T6MatrixTfVii4Vii4ZQs (this=..., __HID131=0x7fffffffcf20) at ../inochi2d/source/inochi2d/math/transform.d:88
88 return trs;
(gdb) bt
#0 0x0000555555bd9c85 in _D8inochi2d4math9transform9Transform6matrixMFZS6inmath6linalg__T6MatrixTfVii4Vii4ZQs (this=..., __HID131=0x7fffffffcf20) at ../inochi2d/source/inochi2d/math/transform.d:88
#1 0x0000555555bbefd3 in _D8inochi2d4core5nodes4part4Part__T8drawSelfVbi1ZQoMFZv (
this=0x7ffff6a5c660) at ../inochi2d/source/inochi2d/core/nodes/part/package.d:345
#2 0x0000555555bbd792 in inochi2d.core.nodes.part.Part.renderMask(bool) (this=0x7ffff6a5c660,
dodge=false) at ../inochi2d/source/inochi2d/core/nodes/part/package.d:661
#3 0x0000555555bbe034 in inochi2d.core.nodes.part.Part.drawOne() (this=0x7ffff6a60990)
at ../inochi2d/source/inochi2d/core/nodes/part/package.d:826
#4 0x0000555555bc5a6d in inochi2d.core.puppet.Puppet.draw() (this=0x7ffff69df8a0)
at ../inochi2d/source/inochi2d/core/puppet.d:510
#5 0x0000555555a0a7b5 in creator.viewport.model.incViewportModelDraw(inochi2d.math.camera.Camera) (
camera=0x7ffff69cf080) at source/creator/viewport/model/package.d:229
#6 0x0000555555a0d546 in creator.viewport.incViewportDraw() ()
at source/creator/viewport/package.d:37
#7 0x00005555559bfe7b in creator.panels.viewport.ViewportPanel.onUpdate() (this=0x7ffff69cf200)
at source/creator/panels/viewport.d:117
#8 0x00005555559b0e94 in creator.panels.Panel.update() (this=0x7ffff69cf200)
at source/creator/panels/package.d:121
#9 0x00005555559b0f91 in creator.panels.incUpdatePanels() () at source/creator/panels/package.d:158
#10 0x00005555558b6aa2 in app.incUpdate() () at source/app.d:135
#11 0x00005555558b6a16 in D main (args=...) at source/app.d:97

Reproduction

  1. Add two Part object
  2. Set one Part object to another.
  3. Remove that Part object.

System Architecture

x86_64

Operating System

Linux

Version

No response

Logs

No response

Additional Context

No response

This is caused because removed Part object is not removed from nodes.masks of related nodes at incDeleteChildWithHistory.
But nodes.masks is removed without any undo history, so if we removed Part object from nodes.masks, there's no way to restore nodes.masks state on undo.

Since it's already on the undo stack which would make the reference non-stale; I think the best way to solve the issue would be to only delete the mask completely if the history is emptied, otherwise check if the parent is null for the mask, and if it is; ignoring it.

I sent PR for this fix. (#293)
It seems working well on my environment.