In fact, ShadingSystemImpl::optimize_group() is just such an example where a context is allocated (for anything that needs to be run during optimization that might need a shading context, like checking on textures), but it returns the context without ever calling execute().