Ouch !... This would tremendously slow down the rendering. To prevent such bad surprises, I need to change how GL debugging is activated and make it so it cannot survive a session restart unless specifically requested by the user.
For next release, I replaced the persistent "RenderDebugGL" debug setting with a new "DebugGLOnRestart" setting, that gets immediately reset to FALSE after use (i.e. after copying its value to the gDebugGL global variable on startup), and only gDebugGL is now toggled during the session (still in the "Advanced" -> "Rendering" -> "Render tests" menu), meaning that if you do need to debug GL from the very start of the rendering, i.e. as soon as the GL initialization is performed (and only in that case), then you must manually set "DebugGLOnRestart" to TRUE before restarting the viewer, or pass the "--set DebugGLOnRestart 1" option in the viewer command line used to start the debug session.
I changed the code to test for a new gGL.mValid flag instead (which is true only after OpenGL got properly initialized for the calling thread and goes false as soon as it gets stopped, which happens before the corresponding GL context is destroyed).
I also added the same check in clear_glerror(), cleaned up a few misplaced stop_glerror() and replaced some with clear_glerror() (which works to clear GL errors where actually needed even when gDebugGL is false).
It still does not explain why WER gets triggered while the viewer unregisters itself from this "service"... Perhaps because the crashes happen in threads after the viewer crash handler gets unregistered by Windows on viewer exit ?
Yet, for good measure, I now also unregister SLPlugin.exe, SLVoice.exe and dullahan_host.exe from WER on viewer startup.
I will send you in PM a link to a test build, so that you can verify on your system that the shutdown issue is properly fixed...
EDIT: link PMed.