Skip to content

fix: multiple crash and safety issues#1306

Open
markreidvfx wants to merge 7 commits into
AcademySoftwareFoundation:mainfrom
markreidvfx:nas_contrib_crash_fixes_v1
Open

fix: multiple crash and safety issues#1306
markreidvfx wants to merge 7 commits into
AcademySoftwareFoundation:mainfrom
markreidvfx:nas_contrib_crash_fixes_v1

Conversation

@markreidvfx

Copy link
Copy Markdown
Contributor

Linked issues

N/A

Summarize your change.

A collection of crash fixes and safety improvements found during internal testing and AddressSanitizer analysis. These are independent fixes grouped together for convenience.

Describe the reason for the change.

  1. GL version error on startup: SessionIPNode queried GL state during construction before the correct context was current, returning wrong capabilities or crashing in multi-window setups.

  2. Dangling preferences window pointer: Non-owning raw pointer to the preferences window could dangle after the window was destroyed. Replaced with QPointer.

  3. Dangling global settings pointer: PackageManager did not null its global settings pointer after deletion.

  4. Uninitialized GL IDs in TextureDescription: id and bufferId were not initialized, so gcTextures() could call glDeleteBuffers on garbage values, destroying unrelated live GL buffers.

  5. Null order properties in PaintIPNode: Missing null check for order properties.

  6. Null session pointer in command modules: ~190 command entry points dereferenced Session::currentSession() without checking for null, risking crashes during teardown or before a session is fully initialized.

  7. Dangling session pointer after destruction: Session::~Session() did not null m_currentSession when the active session was destroyed, leaving a dangling pointer. Also removes a duplicate m_currentSession declaration from RvSession.h that shadowed the base class member.

Describe what you have tested and on which operating system.

Tested on Rocky Linux 9. Several of these issues were identified with AddressSanitizer.

Add a list of changes, and note any that might need special attention during the review.

  • SessionIPNode.cpp: Defer GL queries to first render pass.
  • RvApplication.h: Use QPointer for preferences window reference.
  • PackageManager.cpp: Null global settings pointer after deletion.
  • ImageRenderer.h: Zero-initialize id and bufferId in TextureDescription.
  • PaintIPNode.cpp: Add null check for order properties.
  • CommandsModule.cpp, MuUICommands.cpp, PyUICommands.cpp, IPMu/CommandsModule.cpp: Add null session checks to ~190 command entry points. This is the largest change and touches many functions.
  • Session.cpp, RvSession.h: Null m_currentSession in destructor; remove duplicate declaration.

If possible, provide screenshots.

N/A

Prevents a dangling pointer when the current session is destroyed.

Remove the duplicate m_currentSession declaration from RvSession.h.
The member is already declared in the base class Session.h, and the
duplicate in the derived class shadows it.

Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Session::currentSession() can return null during teardown or before
a session is fully initialised. ~190 command entry points across
CommandsModule, MuUICommands, PyUICommands, and IPMu/CommandsModule
were dereferencing the pointer without checking, risking a null
pointer crash from any Mu or Python command invoked at the wrong
time.

Add null checks that throw a descriptive exception ("no current
session") before each use, turning undefined behaviour into a
catchable error.

Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
The constructor did not initialize id or bufferId, so newly allocated
objects contained whatever garbage the allocator returned.
gcTextures() could then call glDeleteBuffers on these junk values,
potentially destroying unrelated live GL buffers.

Zero-initialize both fields in the constructor.

Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
SessionIPNode called queryGLIntoContainer() during construction, which
queries glGetString(GL_VERSION) etc. At that point, the correct GL
context is not guaranteed to be current on the calling thread. In a
multi-window process another window's context could be active,
returning wrong GL capabilities or no valid context at all.

Split property declaration from GL querying: declareGLProperties()
registers all opengl.* slots with zero/empty defaults at construction
time. The real values are populated later by queryAndStoreGLInfo()
during the first render pass, where makeCurrent() ensures the correct
context is active.

Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant