Visual C++ 8 - Example Crashes with Access Violation
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
Brown Gabe wrote:
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
<snip>
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???
--
Others may have more intelligent, or more focused, suggestions, but here are two things to check: 1) 0xcccccccc looks very much like the contents of an uninitialized variable when running under the debug heap management code. My guess is that you are using an uninitialized pointer value whose contents are 0xcccccccc. See http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c9535__1 the follow the "continued" link to the second page. The fill values are listed there. 2) I assume you're using VS 2005? The Debug | Exceptions... dialog lets you set it to break when an exception is thrown, rather than fielding an unhandled exception. I don't know anything about debugging threads, though. Best of luck, Rush
This is really a strange behavior. I can your sample app in VC 2003 without any crashes... Try to comment the output to std::cout after your timer has elapsed... Maybe there is a problem with writing to streams and cout somehow does not block and main exists while cout is written... ? On Thu, April 27, 2006 2:42, Rush Manbert said:
Brown Gabe wrote:
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
<snip>
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???
--
Others may have more intelligent, or more focused, suggestions, but here are two things to check:
1) 0xcccccccc looks very much like the contents of an uninitialized variable when running under the debug heap management code. My guess is that you are using an uninitialized pointer value whose contents are 0xcccccccc.
See http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c9535__1 the follow the "continued" link to the second page. The fill values are listed there.
2) I assume you're using VS 2005? The Debug | Exceptions... dialog lets you set it to break when an exception is thrown, rather than fielding an unhandled exception. I don't know anything about debugging threads, though.
Best of luck, Rush
I tried commenting out the std::cout call and it still crashes for some
reason. I'm trying to track down the problem to the uninitialized memory
but I can't seem to locate it for some reason. I tried implementing a
slight simplier version to try and track down the fault.
Can anyone reproduce this error on a vanilla install of Visual Studio 2005?
I'm wondering if this is a VC8 flaw for Boost or just some weird libraries
that I'm using with boost.
Here is the sample code:
==============[Sample Code]=====================
void ThreadTest() {
return;
};
int main(int argc, char* argv[])
{
boost::thread thrd(ThreadTest);
thrd.join();
return 0;
}
==============[Sample Code]=====================
On 4/27/06, Ovanes Markarian
This is really a strange behavior. I can your sample app in VC 2003 without any crashes...
Try to comment the output to std::cout after your timer has elapsed... Maybe there is a problem with writing to streams and cout somehow does not block and main exists while cout is written... ?
Brown Gabe wrote:
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
is but I can't seem to determine the problem. I'm using the plain example thread.cpp
<snip>
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???
--
Others may have more intelligent, or more focused, suggestions, but here are two things to check:
1) 0xcccccccc looks very much like the contents of an uninitialized variable when running under the debug heap management code. My guess is that you are using an uninitialized pointer value whose contents are 0xcccccccc.
See http://www.codeguru.com/cpp/w-p/win32/tutorials/article.php/c9535__1 the follow the "continued" link to the second page. The fill values are listed there.
2) I assume you're using VS 2005? The Debug | Exceptions... dialog lets you set it to break when an exception is thrown, rather than fielding an unhandled exception. I don't know anything about debugging threads,
On Thu, April 27, 2006 2:42, Rush Manbert said: problem though.
Best of luck, Rush
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- -Gabe
On 4/27/06, Brown Gabe
Can anyone reproduce this error on a vanilla install of Visual Studio 2005? I'm wondering if this is a VC8 flaw for Boost or just some weird libraries that I'm using with boost.
It doesn't crash on my VC8.
Brown Gabe wrote:
I tried commenting out the std::cout call and it still crashes for some reason. I'm trying to track down the problem to the uninitialized memory but I can't seem to locate it for some reason. I tried implementing a slight simplier version to try and track down the fault.
Can anyone reproduce this error on a vanilla install of Visual Studio 2005? I'm wondering if this is a VC8 flaw for Boost or just some weird libraries that I'm using with boost.
Here is the sample code:
==============[Sample Code]=====================
void ThreadTest() {
return;
};
int main(int argc, char* argv[]) {
boost::thread thrd(ThreadTest); thrd.join();
return 0; }
==============[Sample Code]=====================
I tried this code, then a variant of this code, then the code you supplied in your first post, and they all ran without error in both Debug and Release build configurations. I made a Win32 console app using static Boost libraries and the static runtime. My Visual Studio 2005 installation is very new and totally vanilla. I guess this helps point you at some other library. I still wonder, can't you set a breakpoint to trigger when the exception is thrown? If you break at that point, the offender should be on the stack. - Rush
What I can imagine in regards of this failure is that you have in your watch expressions some pointer dereference. And this ptr is not valid... I had this error once in VC 6.0 and spent almost 3 hours looking for this kind of problem... Please analyse your watch expressions carefully. May be you have argv[1] in your watch or some other context valid name, which is not initialized. As I can remember this was fixed in VC 2002, but can come up in VC 8 again. Best Regards, Ovanes -----Ursprüngliche Nachricht----- Von: Rush Manbert [mailto:rush@manbert.com] Gesendet: Thursday, April 27, 2006 22:44 An: boost-users@lists.boost.org Betreff: Re: [Boost-users] Visual C++ 8 - Example Crashes with Access Violation Brown Gabe wrote:
I tried commenting out the std::cout call and it still crashes for some reason. I'm trying to track down the problem to the uninitialized memory but I can't seem to locate it for some reason. I tried implementing a slight simplier version to try and track down the fault.
Can anyone reproduce this error on a vanilla install of Visual Studio 2005? I'm wondering if this is a VC8 flaw for Boost or just some weird libraries that I'm using with boost.
Here is the sample code:
==============[Sample Code]=====================
void ThreadTest() {
return;
};
int main(int argc, char* argv[]) {
boost::thread thrd(ThreadTest); thrd.join();
return 0; }
==============[Sample Code]=====================
I tried this code, then a variant of this code, then the code you supplied in your first post, and they all ran without error in both Debug and Release build configurations. I made a Win32 console app using static Boost libraries and the static runtime. My Visual Studio 2005 installation is very new and totally vanilla. I guess this helps point you at some other library. I still wonder, can't you set a breakpoint to trigger when the exception is thrown? If you break at that point, the offender should be on the stack. - Rush
I think I fixed my problem. I scrapped the entire Visual Studio project and
created a brand new one from scratch including all libraries and dll's.
Works like a charm now. I guess the problem I was having must have been
some weird linking issues. Oh well! Thanks for you help guys!
On 4/28/06, Ovanes Markarian
What I can imagine in regards of this failure is that you have in your watch expressions some pointer dereference. And this ptr is not valid... I had this error once in VC 6.0 and spent almost 3 hours looking for this kind of problem... Please analyse your watch expressions carefully. May be you have argv[1] in your watch or some other context valid name, which is not initialized.
As I can remember this was fixed in VC 2002, but can come up in VC 8 again.
Best Regards, Ovanes
-----Ursprüngliche Nachricht----- Von: Rush Manbert [mailto:rush@manbert.com] Gesendet: Thursday, April 27, 2006 22:44 An: boost-users@lists.boost.org Betreff: Re: [Boost-users] Visual C++ 8 - Example Crashes with Access Violation
Brown Gabe wrote:
I tried commenting out the std::cout call and it still crashes for some reason. I'm trying to track down the problem to the uninitialized memory but I can't seem to locate it for some reason. I tried implementing a slight simplier version to try and track down the fault.
Can anyone reproduce this error on a vanilla install of Visual Studio 2005? I'm wondering if this is a VC8 flaw for Boost or just some weird libraries that I'm using with boost.
Here is the sample code:
==============[Sample Code]=====================
void ThreadTest() {
return;
};
int main(int argc, char* argv[]) {
boost::thread thrd(ThreadTest); thrd.join();
return 0; }
==============[Sample Code]=====================
I tried this code, then a variant of this code, then the code you supplied in your first post, and they all ran without error in both Debug and Release build configurations. I made a Win32 console app using static Boost libraries and the static runtime. My Visual Studio 2005 installation is very new and totally vanilla. I guess this helps point you at some other library.
I still wonder, can't you set a breakpoint to trigger when the exception is thrown? If you break at that point, the offender should be on the stack.
- Rush
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- -Gabe
participants (4)
-
Brown Gabe
-
Olaf van der Spek
-
Ovanes Markarian
-
Rush Manbert