Application crash in latest Nvidia driver while calling glClientWaitSync

Using the latest driver version 456.38 on Windows using a 1050 I am able to reproduce the crash using this code.

void render() {
  GLsync fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
                
  GLbitfield waitFlags = 0;
  GLuint64 waitDuration = 0;
  while (true) {
    auto waitRet = glClientWaitSync(fence, waitFlags, waitDuration);
    if (waitRet == GL_ALREADY_SIGNALED || waitRet == GL_CONDITION_SATISFIED) {
      break;
    }
    if (waitRet == GL_WAIT_FAILED) {
      break;
    }
    waitFlags = GL_SYNC_FLUSH_COMMANDS_BIT;
    waitDuration = 1000000000;
  }
  glDeleteSync(fence);
}

Also note that this code works on Linux using the Nvidia driver version 455.23.

Is there any way to work around this? Any help would be appriciated.

I’ve narrowed the problem down to a shader execution. The following fragment shader, after execution causes the driver to crash at the next client sync point:

layout (binding = 0) uniform samplerCubeArray texEnv;

in Shared {
	vec3 uv;
} pass;

layout (location = 0) out vec4 oColor;

void main() {

	vec3 N = normalize(pass.uv);

	vec3 irradiance = vec3(0.0);

	vec3 up = vec3(0.0, 1.0, 0.0);
	vec3 right = normalize(cross(up, N));
	up = cross(N, right);

	// Integrate over the hemisphere
	float sampleDelta = 0.025;
	float sampleCount = 0.0;
	for (float phi = 0.0; phi < 2.0 * PI; phi += sampleDelta) {
		for (float theta = 0.0; theta < 0.5 * PI; theta += sampleDelta) {
			// Convert spherical coords to cartesian (in tangent space)
			vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));

			// Tangent space to world space conversion
			vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * N;

			irradiance += texture(texEnv, vec4(sampleVec, 0.0)).rgb * cos(theta) * sin(theta);
			++sampleCount;
		}
	}

	irradiance *= PI / float(sampleCount);

	oColor = vec4(irradiance, 1.0);
}

If I replace the shader with a stub shader that simply samples the cube map array with the passed in uv coords no crash occurs. Again note that all this code works on the Linux Nvidia driver version 455.23.

Edit: If I increase the sampleDelta to 0.1 the crash doesn’t occur so this seems to be timing based.