When I try to build my program from source the results are very random. Sometimes it compiles just fine and other times it will either give a -11 error with no build log or it will give an "Unhandled exception at ...." error and break at

void __cdecl _unlock_fhandle (
int fh
LeaveCriticalSection( &(_pioinfo(fh)->lock) );

in osfinfo.c

The error always takes place while running clBuildProgram so it doesn't appear to be a problem with my c++ code and given that the kernel sometimes does compile and the lack of a build log I don't think it's a problem with my kernel code (It's a reasonably long kernel, about 400 lines of code and takes about 6 minutes to compile). I'm working in VS 10 Express in Windows 7 and my video card is an ATI HD5870 and as far as I know the drivers are all up to date. Any insights would be greatly appreciated.