multithreaded reeading and writing from buffer
The last years, 99% of my time I'm doing java so my C++ skills are well, erm, lets's say a bit at a low level.
But I'm having a bit of a problem.
I have a buffer that is accessed by two threads.
One for reading and one for writing to the buffer (a vector).
I'm pretty sure that I never write outside the memory allocated by the buffer.
Due to performance issues we tryed removing 2 mutex locks and that worked CPU usage droped with 50%. We made the methods where we removed the mutex locks a bit smarter so we first check if we can safely read or not.
That code isn't 100% safe because things can still go wrong between the check and the actual read.
Now, about 2 or 3 times a day, we get a blue screen on Win XP and immediately after a reset of windows.
Can this be the result of a push and pop on the same address?
As far as I know, if I try to write beyond my allocated memory I would get an access violation message but windows wouldn't reset. Is this the same with reading and writing to the same address?
I analysed the mini dumps from windows but that didn't give me any usefull information.
I haven't been able to simulate it on the development machine with debuging capabilities nor am I allowed post any code.
I also ran it with the ntsd but it hasn't crashed yet.
Could the windows crash be related to our program or can it be a hardware fault (like a heat problem)?
Last edited by maes; 08-20-2007 at 02:39 AM.
I doubt you're causing the blue screen with that program unless your code is part of a driver (in which case unsafe thread code is a really baaaaaaaaad idea), or something else of that nature.
Windows NT based systems, such as XP, are pretty stable and don't usually blue screen unless there is a driver problem or something hardware related.
I agree, it's very unlikely that you will crash the system with a user-mode application (unless you are talking to a borken driver of course).
What is the bluescreen error you get?
Officially An Architect
Unlikely, since the problem only appeared once you changed your code. You might spend all week speculating why Windows crashes, but that's probably not a good use of your time since you might find another box where it doesn't crash. Just fix the code and chalk it up to "Who knows with Windows."
Originally Posted by maes
Originally Posted by matsp
The blue screen disapears to quickly the computer resets immediatly after.
But I think you're all right. Last night I had the original program running and it still did a reboot.
So I doubt it will be a bug in our program.
Thanks for the help,
if i do not remember wrong you can download the tweakui utility from microsoft and disable the immediate reboot with it. then you are able to read the blue screen message.
Yes - in fact, it doesn't take a TweakUI either - just go to Control-Panel->System->Advanced and unclick "Automatically reboot" - or if you have a minidump, you should be able to see the fault that caused the dump.
Originally Posted by pheres