1

I have one exe which collect some information and once information collected saved in local machine. I have managed loop such that it will do same task for infinite time.

But exe stops execution after couple of hours (approx 5-6 hours), it neither crashed nor gives exception.

I tried to find reason in windbg but I haven't got any exception in it.

Now, Could anyone help me to detect problem?

should I go for sysinternal tool or any other, which debugger tool should I use?

Sam
  • 433
  • 1
  • 10
  • 26
  • If it does not crash, then perhaps it is hung somewhere, such as a deadlock. Attach WinDbg to it and check "!uext.runaway f". Are any of the threads extremely long running? Also, it would help if could you state whether the application is native or managed. – Dono Aug 14 '14 at 06:28
  • It's either hung or your loop has met a condition that isn't handled correctly so continues indefinitely doing nothing. You can attach windbg and execute `!locks` or `!cs -s -l -o` to see if any critical sections are locked, if so see which threads are waiting on which critical sections and then check the call stacks of those threads. You can also dump all the call stacks and inspect them `~* kb` – EdChum Aug 14 '14 at 07:07
  • I would suggest "watching" the program exit points, if you are certain that neither crash nor exception is thrown. You can place breakpoints there or place some debug messages, like console output or Windows MessageBox. – Rolice Aug 15 '14 at 22:14

2 Answers2

2

A few things jump to mind that could be killing your program:

  • Out of memory condition
  • Stack overflow
  • Integer wrap in loop counter

Programs that run forever are notoriously difficult to write correctly, because your memory management must be perfect. Without more information though, it's impossible to answer this question.

Wug
  • 12,956
  • 4
  • 34
  • 54
  • 1
    `Out of memory` and `Stack Overflow` would trigger an exception?! The loop counter is possible though. To OP: The question is if it's a hot or a cold stack, easily viewed with any taskmonitor of your choice. Is the process running at 100% or is it idle? Windbg is the right tool for the job. Have you tried `analyze -v -hang`? Can you post the dumpfile and/or the results? – Lieven Keersmaekers Aug 14 '14 at 05:55
  • It depends on what language your program is written in. Since he's using windbg, I suspect it's C or C++ (but it wasn't specified in the question). None of those things will trigger exceptions in C++, and C doesn't even have exceptions. – Wug Aug 15 '14 at 07:06
  • tx, I didn't know that. Getting a bit up to speed, it seems that an [unhandled OOM](http://eli.thegreenplace.net/2009/10/30/handling-out-of-memory-conditions-in-c/) would trigger a segfault pretty soon wouldn't it? The application would die pretty soon after that. I can't find much if anything about how unhandled applications progress after having Stack Overflow's unfortunatly. – Lieven Keersmaekers Aug 15 '14 at 10:45
  • It depends entirely on how the program's written and without more information, I can't conclusively answer. – Wug Aug 16 '14 at 03:51
0

If the executable is not yours and is Naitive C/C++ code, you may want to capture first chance exception dumps or monitor the exe using Windows debug tools (such as DebugDiag or ADPlus).

Alternatively, if you have access to the developer of the executable, they may add more tracing to the exe (ETW or otherwise) to understand the possible failure points in the code.

4444
  • 3,541
  • 10
  • 32
  • 43
Addy
  • 731
  • 5
  • 15