Intermittent crash caused in a Compute Shader

Every 5 times or so, a Compute Shader that is always executed makes my program to crash. The error message is: “Unhandled exception at 0x0000000063648789 (nvoglv64.dll): Fatal program exit requested.” I can’t find the reason why it crashes as I check if the indices are out of the boundary. This is the code:

#version 430 core

layout(local_size_x = 8, local_size_y = 8, local_size_z = 8) in;

struct triangle
{
	uint i0;
	uint i1;
	uint i2;
};

layout(std430, binding = 2) buffer trianglesIndicesList
{
	triangle meshTriangles[];
};

layout(std430, binding = 3) buffer edgeIndicesMap
{
	uint edgesIndices[];
};

uniform uvec3 indicesDims;

void main()
{
	if (gl_GlobalInvocationID.x >= indicesDims.x ||
		gl_GlobalInvocationID.y >= indicesDims.y ||
		gl_GlobalInvocationID.z >= indicesDims.z)
		return;

	uint triangleIndex = gl_GlobalInvocationID.x + gl_GlobalInvocationID.y * indicesDims.x + gl_GlobalInvocationID.z * indicesDims.x * indicesDims.y;

	if (triangleIndex >= meshTriangles.length())
		return;

	uint nChanges = 0;
	bool changed[3] = bool[3](false, false, false);
	triangle t = meshTriangles[triangleIndex];
	
	for (uint i = 0; i < edgesIndices.length(); ++i)
	{
		uint eIndex = edgesIndices[i];

		if (t.i0 == eIndex && !changed[0])
		{
			t.i0 = i;
			++nChanges;
			changed[0] = true;
		}
		else if (t.i1 == eIndex && !changed[1])
		{
			t.i1 = i;
			++nChanges;
			changed[1] = true;
		}
		else if (t.i2 == eIndex && !changed[2])
		{
			t.i2 = i;
			++nChanges;
			changed[2] = true;
		}

		if (nChanges == 3)
			break;
	}

	meshTriangles[triangleIndex] = t;
}

I am using Windows 10 x64 and I have a NVIDIA GeForce GTX 760 with drive version 26.21.14.3086.

Does anyone see what I am doing wrong? Thank you very much!

It seems the problem was the time. The execution was a few seconds. I guess the SO was finishing the shader execution. I improved the shader and now the problem is gone.