cudaThreadSynchronize() error

I have a strange problem about this function.I use it in my code after the kernel.But when I debug the code step by step ,it often exit automatically at cudaThreadSynchronize().And the output window shows :cudaerror_enum occurs in memory 0x00125750.

[codebox]BemCal<<<grid,block>>>(d_obs,d_src,d_preal,d_pimag,njgroup);

 //copy device result to host

 cudaThreadSynchronize();

 cudaGetLastError();[/codebox]

Who knows the reason?

You can try and use checkCUDAError() function. You could use it after the kernel call and see whether the kernel is properly executed or not.