Boost logo

Boost Users :

From: Brown Gabe (gabosgab_at_[hidden])
Date: 2006-04-26 17:21:35


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 <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net