What to do when the program crashes

Hi,

It seems my program often crashes <img src=‘http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/crying.gif’ class=‘bbc_emoticon’ alt=’:’(’ /> I guess it’s because it writes to the memory of graphic card, so when I debug, I have to restart the machine very often. Is there any other way to solve the problem without restarting the computer? Thanks.

Any “normal” program crash shouldn’t pose a problem. I’ve only noticed problems that require a restart when I write past the end of an allocated global memory array. Or by writing into shared memory when forgetting to allocate that shared memory in the kernel call.

So, the short answer is: don’t write past the end of allocated arrays :)

If you compile in emulation mode and run in a debugger, you are likely to get a seg fault when your program does this. The debugger can tell you where it is occuring so you can prevent it from happening again. You are also less likely to need a reboot when such a crash occurs in emulation mode.

Or the start ! Here is one of the classic errors that does both:

for (y=0; y<height; ++y)

  for (x=0; x<width; ++x)

    average = ( data[y*width + x-1] + data[y*width + x]  + data[y*width + x+1]) /3.0;

Peter