Repository navigation
Description
Bug
src/gl/win.rs panics the whole host process when the temporary GL context cannot provide wglChoosePixelFormatARB:
wglChoosePixelFormatARB.unwrap()( // <- panics: called `Option::unwrap()` on a `None` valueAt rev 70e4e05ba1de837970b5b5457a99893aae0b6cfa this is line 227, but the pattern holds for current code: after creating the throwaway context you call wglGetProcAddress(wglChoosePixelFormatARB) and .unwrap() the result. wglGetProcAddress returns NULL when:
- the runner has no OpenGL driver at all (GitHub
windows-latestCI runners — this is how we hit it), or - the temporary window's pixel format lacks
PFD_SUPPORT_OPENGL/driver support so the temp context isNULL(WGL extensions require a current context).
A DAW hosting this as a plugin editor then has its entire process unwound across a C boundary — a plugin GUI should fail, not murder the host.
Reproduction (no GPU needed)
Any CLAP host that embeds a baseview-based plugin (e.g. Bus-Channel-Strip, built on nice-plug + vizia-plug + this fork) on a GPU-less Windows runner:
- Load plugin,
clap.gui->create("win32", false),set_parent(host_container_hwnd). ext_gui_set_parent→ editor spawn → baseview window creation →gl::win::create_context→ paniccalled Option::unwrap() on a None valueatgl/win.rs:227.
Evidence: slooper (a FOSS DAW) CI run https://github.com/actually-god/slooper/actions/runs/47373675326 recorded exactly this panic inside the guiCreate chain. (Our host survives it only because every plugin call is wrapped in catch_unwind + loader lock — most hosts don't.)
Expected
create_context returns Err(GlError::...) when wglChoosePixelFormatARB is unavailable (or falls back to ChoosePixelFormat/wglUseFontBitmaps-era pixel formats, or software GL), instead of unwrap()-panicking. The caller already models GL-init failure via Result.
Suggested patch shape
let Some(choose) = wglChoosePixelFormatARB else {
return Err(GlError::CreationFailed(CreationFailedError::InvalidFBConfig));
};
choose(hdc, pixel_format_attribs.as_ptr(), std::ptr::null(), 1, &mut pixel_format, &mut num_formats);plus checking num_formats > 0 before SetPixelFormat (today pixel_format = 0 on failure feeds DescribePixelFormat(hdc, 0, ...) — undefined-ish).
Same pattern likely applies to the other wgl* unwraps (wglCreateContextAttribsARB, swap-interval functions) — those have #[allow(non_snake_case)]-style optional semantics but are unwrapped unconditionally.
Context: we're hosting vizia/nice-plug CLAP editors cross-OS; full root-cause write-up on our side: https://github.com/actually-god/slooper (card t_b71497b9).
(notes: we hit this via the maintained fork https://github.com/vizia/baseview rev 70e4e05 — issues disabled there — used by nice-plug/vizia-plug plugins such as Bus-Channel-Strip; the same code shape exists upstream.)
Activity