Skip to content

Harden MjrContext cleanup after failed construction - #547

Open
sylvesterkaczmarek wants to merge 2 commits into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/mjr-context-failed-construction
Open

Harden MjrContext cleanup after failed construction#547
sylvesterkaczmarek wants to merge 2 commits into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/mjr-context-failed-construction

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Make MjrContext cleanup safe when renderer construction fails before the GL context reference count is acquired.

Changes

  • initialize _ptr and track whether this MjrContext actually acquired a GL-context reference
  • decrement/free the GL context only when that reference was acquired
  • make ptr and free() safe for partially initialized instances
  • add regression coverage for partial-construction cleanup

Rationale

The framebuffer/context failure reported in #370 can trigger a secondary cleanup exception because __del__() runs on a partially initialized MjrContext. It can also attempt to decrement a GL-context reference count that this object never incremented. This patch addresses that cleanup path only; it does not claim to fix the underlying EGL/framebuffer failure.

Related to #370.

@sylvesterkaczmarek
sylvesterkaczmarek marked this pull request as ready for review August 15, 2026 13:34
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