If a context is current, my reading of the spec is that it’s resources should not be immediately released until after a eglMakeCurrent().
Termination marks all EGL-specific resources associated with the specified display
for deletion. If contexts or surfaces created with respect to dpy are current (see
section 3.7.3) to any thread, then they are not actually released while they remain
current. Such contexts and surfaces will be destroyed, and all future references to
them will become invalid, as soon as any otherwise valid eglMakeCurrent call is
made from the thread they are bound to.
But doesn’t terminating the display, invalidate the parameters needed by the eglMakeCurrent(display, read, write, context) call? I.e. the function must return an EGL_NOT_INITIALIZED error? Or should eglMakeCurrent(display, NULL, NULL, NULL); work even if the display has been terminated. I feel like I’m missing something obvious.
It would make most sense to me if eglTerminate(display) did an implicit eglMakeCurrent(display, 0,0,0);, otherwise I fear memory leaks are unvoidable.