0

Context

I have a .NET 5 console application, which runs into a stack overflow after running approx. three hours. Despite of serious logging, there was nothing useful in the logs.

I do not even know if a) the stack overflow was built up monotonously, starting from the beginning, or b) that there was a runtime condition, what directed the control flow to a branch where the stack overflow built up within a few seconds.

Question

I would like to see which is the case, I also would like to have more diagnostic information when the event occurs. Anyone can point to the right direction, I do not want to reinvent the wheel. I googled it, but except of some C/C++ articles there was no result.

Alenros
  • 816
  • 7
  • 23
g.pickardou
  • 32,346
  • 36
  • 123
  • 268
  • 1
    If you can reproduce while running in the debugger, you can examine the stack when the exception occurs. – Klaus Gütter Jan 10 '21 at 07:45
  • 3
    Since you are doing serious logging, you can try getting the stack depth every time you log, and log that too. You should be able to find out which case it is this way. – Sweeper Jan 10 '21 at 07:52
  • @Sweeper after the very first happiness, I've just got the paranoid idea, what if the stackoverflow happens in **other thread**, which I do not know explicitly, started in by a class lib or wherever, so I do not have log calls in that... – g.pickardou Jan 10 '21 at 08:06
  • 2
    If you able to reproduce the problem (even only without debugger attached), you can try to dump a process then examine the dump with VS or WinDGB - this should show you all thread's stacks. – Serg Jan 10 '21 at 08:26
  • @Serg: This happens on a machine where there is no debugger. How to dump the process? (The only thing I see is my process is terminated process) – g.pickardou Jan 10 '21 at 08:58
  • To create dump you should configure WER via registry. See here https://stackoverflow.com/a/7406368/2011071 or here https://learn.microsoft.com/en-us/visualstudio/debugger/using-dump-files?view=vs-2019 for details. Although some docs says that this do not work for .net code, this actually works fine. – Serg Jan 10 '21 at 09:06
  • You **must** be running something recursively, or have a memory leak to get this. You may find Visual Studio Remote Debugger useful if you are local to the machine on the network. – Charlieface Jan 10 '21 at 11:45

0 Answers0