views:

87

answers:

1

Hello there,

I got this error

Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading location 0x00000090.

and the error points to this line:

        // thread.hpp ln 56
        void run()
        {
            f(); // here <<
        }

When trying to run this code:

void frameFunc()
{
    for(;;)
    {
         //..........do something. it is too long to paste. (calculations)
    }
}

int main()
{
   boost::thread framethread(frameFunc);
   framethread.join();
   //........
}

The error will simply gone when I remove the loop in frameFunc.

Any kind of help would be appreciated :)

+2  A: 

The code that you showed looks valid. I think the problem is inside the code that is not shown.

Brian R. Bondy
and why the program works fine if I remove the loop..
djzmo
You'll probably find that the code will still run fine if you remove only the contents of the loop...
Timo Geusch
Here is an example of why doing something many times may segfault: 1) int x[2];int *p = x; *p=3; 2) p++; *p=4; 3) p++; *p = 7;<-- crash.
Brian R. Bondy