Hi Everyone,
Hopefully this isn't some noob question, but here goes... I'm trying to
run boost 1.3.1 in Visual C++ 8 VC8 and I keep getting an access violation
at the termination of my thread. I've tried looking to see what the problem
is but I can't seem to determine the problem. I'm using the plain example
thread.cpp
====================[ EXAMPLE CODE ]=======================
#include
#include
#include <iostream>
struct thread_alarm
{
thread_alarm(int secs) : m_secs(secs) { }
void operator()()
{
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
xt.sec += m_secs;
boost::thread::sleep(xt);
std::cout << "alarm sounded..." << std::endl;
}
int m_secs;
};
int main(int argc, char* argv[])
{
int secs = 5;
std::cout << "setting alarm for 5 seconds..." << std::endl;
thread_alarm alarm(secs);
boost::thread thrd(alarm);
thrd.join();
}
====================[ EXAMPLE CODE ]=======================
I get the expected out from the application. Upon tracing my code, the
exception only occurs when the worker thread exits.
Exception occured in threadex.c on line 348.
Unhandled exception at 0x7c9012b4 in test.exe: 0xC0000005: Access violation
reading location 0xcccccccc.
" __try {
_endthreadex (
( (unsigned (__CLR_OR_STD_CALL *)(void
*))(((_ptiddata)ptd)->_initaddr) )
( ((_ptiddata)ptd)->_initarg ) ) ;"
Any thoughts on what might cause an error like this???
--
-Gabe