Repository navigation
Conversation
createPbufferSurfaceImpl() returns NULL when wglCreatePbuffer is not
available or fails. createPbufferSurface() pushed that NULL into the
free list and then called refreshDC() on it. A NULL replacement after
a failed refreshDC() went into mLivePbufs and back to the caller.
Stop the refill at the first NULL result: a missing function or an
out-of-resources driver makes the next calls fail too. Return NULL
when the refill creates no pbuffer, or when the replacement is NULL.
Both callers already check for NULL.
Log a failed wglCreatePbuffer with its error code, at the same rate
as the wglReleasePbufferDC warning. Move that rate rule into
shouldLogFailure() for both.
Test: Windows CMake build with clang-cl, target EGL_translator_static.
Found by code review; not seen at run time.
Assisted-by: Claude Code:Claude-Opus-5.5
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.
Problem
Fixes #247.
WglDisplay::createPbufferSurface()does not check the result ofcreatePbufferSurfaceImpl().That function returns NULL when
wglCreatePbufferis not available or fails.mFreePbufs. Then the code callsrefreshDC()onfreeElts.back(). If that entry is NULL, this dereferences NULL.refreshDC(), the replacement can also be NULL. The code inserts it intomLivePbufsand returns it.createPbufferSurfaceImpl()also drops theGetLastError()code, so the failure is not logged.Fix
calls fail too.
refreshDC()is NULL, return NULL. Do not insert it intomLivePbufs. The old pbuffer stays inmDeletePbufs, as before.wglCreatePbufferwith its error code: the first 8 failures, then at powers oftwo. The new
shouldLogFailure()holds this rule.releasePbuffer()used the same rule inline(egl: return WGL pbuffers to the pool when DC release fails #239) and now calls it.
Both callers already check for NULL:
eglCreatePbufferSurface()setsEGL_BAD_ATTRIBUTEandreturns
EGL_NO_SURFACE, and~EglContextskips themakeCurrent()(debug builds stop at itsassert). The GLX backend does not change: itscreatePbufferSurfaceImpl()never returns NULL.Test
Windows CMake build with clang-cl, target
EGL_translator_static: completes. We found this by codereview. We did not see it occur.
This change was developed with AI assistance (Claude Code; see the
Assisted-bytrailer).