clEnqueueReadBuffer fails with BSOD

Hi, I have a problem that I can not explain.

On the second iteration clEnqueueReadBuffer hangs the system and it goes to BSOD saying that infinite loop at video adapter detected.

Any suggestions what am I doing wrong?

Here is the outline of the algorithm:

1. Init all variables, queues, kernels, writing data to buffers and so on
//here's the basic cycle goes:
2. do{
   2.1. Write buffer to "Nebalans" kernel
   2.2. clEnqueueNDRangeKernel Nebalans
   2.3. Read buffers from "Nebalans" kernel
   2.4. clFinish(queue)

   2.5. clEnqueueNDRangeKernel JacobiForm
   2.7. Read buffers from "JacobiForm" kernel
   2.8. clFinish(queue)
   
   2.9. for (i = 1..N)
       2.9.1. for (j = 0..i)
            2.9.1.1. clCreateBuffer(-s)
            2.9.1.2. clSetKernelArg (for kernel SAXPY_cond)
            2.9.1.3. clEnqueueNDRangeKernel SAXPY_cond
            2.9.1.4. Read data from kernel SAXPY_cond
            2.9.1.5. clFinish
            2.9.1.6. Release mem objects
}while (EndCondition())

code is here

damn…what the?..

I removed all clFinish() and everything works fine.
Why? :confused: