简体   繁体   中英

Different behaviour of code (debugging or not & different computers)

I have created a program which runs 2 threads synchronized using events ( SetEvent() , WaitForSingleObject() , WaitForMultipleObjects() ) in Visual Studio 2010. The following happens:

  • when I run this program using the debugger it runs for a certain time and then crashes

  • when I run this program without debugging (.exe file) it crashes directly

  • when I run this program in another computer using the debugger it crashes immediately and via .exe file it crashes after some time

The following error has been reported when debugging:

Unhandled exception at 0x5eafcaf7 (msvcr100d.dll) in test.exe: 0xC0000005: Access violation reading location 0x0036f000.

Could somebody bring some light to this topic as I don't know where to start searching? Which is the difference between running the code in the debugger or without? (Which kind of code is added?) Why do the different computers have different behaviours when running the same code?

In both computers there is exactly the same operating system (Windows 7) and I assume the same libraries and patches.

Thank you for your help!


EDIT 11.12.2012

I have installed Application Verifier and get in Visual Studio some errors displayed as this:

=========================================================== 
VERIFIER STOP 0000000000000013: pid 0x1E18: first chance access violation for
current stack trace

000000000874F000 : Invalid address being accessed
000000005201CAF7 : Code performing invalid access
000000000009E440 : Exception record. Use .exr to display it.
000000000009DF50 : Context record. Use .cxr to display it.
===========================================================

Does somebody know how I can see which address belongs to which line of code to know exactly where the exception occurs? I have also read in the Help of the program that using the command "!heap p -a ACCESS_ADDRESS" should give details about the nature of the error and what heap block is overrun. Where should I place this command using Visual Studio?

When working in a multi-threaded environment, things can happen at different speeds on different threads. Trying to identify the possible cause without the relevant code is quite difficult.

The error is a general memory access violation error. This usually occurs when a variable being returned from a function is bigger than expected, or different type.

Can we see the code please?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM