19

I have a windows service that does some intensive work every one minute (actually it is starting a new thread each time in which it syncs to different systems over http). The problem is, that after a few days it suddenly stops without no error message.

I have NLog in place and I have registered for AppDomain.CurrentDomain.UnhandledException. The last entry in the textfile-log is just a normal entry without any problems. Looking in the EventLog, I also can't find any message in the application log, however, there are two entries in the system log.

One basically says that the service has been terminated unexpectedly. Nothing more. The second event (at the same time as the first one) says: "...A new guard page for the stack cannot be created..."

From what I've read, this is probably a stack overflow exception. I'm not parsing any XML and I don't do recursive work. I host a webserver using Gate, Nancy and SignalR and have RavenDB running in embedded mode. Every minute a new task is started using the Taskfactory from .NET 4.0 and I also have a ContinueWith where I re-start a System.Timers.Timer to fire again in one minute.

How can I start investigating this issue? What could be possible reasons for such an error?

1
  • 3
    Yes, it is an SO. It isn't managed code, it reports the exception differently. You got a bunch of code you didn't write, it is all suspect. Commented Jun 27, 2012 at 0:58

6 Answers 6

19

Based on the information that you provided, I would at least, at the minimum, do the following:

  1. Pay extra attention to any third party calls, and add additional info logging around those points.
  2. There are some circumstances in which AppDomain.CurrentDomain.UnhandledException won't help you - a StackOverflowException being one of them. I believe the CLR will simply just give you a string in this case instead of a stack trace.
  3. Pay extra attention around areas where more than one thread is introduced.

An example of an often overlooked StackOverflowException is:

private string myString; public string MyString { get { return MyString; } } //should be myString 
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for your answer! I'll try to discard the Task.New.ContinueWith thing and see if that makes any difference. One question - could it also be a System.OutOfMemoryException?
@DanielLang: Yes that is also possible.
@BryanCrosby is it possible to get a System.OutOfMemoryException and not get it logged specifically in the Appliaction section of the event viewer?
it is definitely a system out of memory exception. and It's not necessarily your app causing it. it could be something happening on the system in question.
5

I got this on a particular computer and traced it to a c# object referencing itself from within an initializer

1 Comment

In my case, I was accidentally recursively calling a method, and this was causing a stack overflow.
4

Just as a 'for what it is worth' - in my case this error was reported when the code was attempting to write to the Windows Event Log and the interactive user did not have sufficient permission. This was a small console app that logged exceptions to a text file and the event log (if desired). On exception, the text file was being updated but then this error was thrown and not caught by the error handling. Disabling the Event Logging stopped the error occurring.

Comments

2

Just in case any other person is having the same problem, in my case I found that my windows service was trapped in an endless recursive loop accidentally. So If anyone else have this problem, take in consideration method calls that may be causing huge recursive loops.

1 Comment

This was also my case that the message was caused by accidental recursive loop
0

I think why you might all be stumped is because this MAY BE a SSD hardware fault. I get this error consistently while playing games about every 3-5 hours and its my computers page file failing somehow.. I know it isnt RAM because i replaced my CPU/RAM/MOBO combo trying to battle this. And its not programming because different games and different apps all fail at the same time, unless its windows corruption?

I could be wrong but just an idea.

I have two samsung evo's in raid

Comments

0

This is an old thread, but I'm posting a solution in case it's helpful for others who stumble upon this weird error.

I started getting this error just ON OPENING Visual Studio 2022. Eventually, I found my "AWS Toolkit with Amazon Q" was the culprit. Removing and reinstalling it did not fix the issue. I worked with ChatGPT and Grok and never could figure what "corrupt lingerings" still remained. I eventually removed it as I found it wasn't needed.

To remove it:

  1. Open Visual Studio in safe mode ("devenv /SafeMode") and view your Extensions (Installed ones),

  2. Remove any potential culprits (AWS, or recently-installed ones),

  3. Close and restart Visual Studio to see if the error went away. If not, the issue might be with another extension.

I hope this helps another developer in the future! :)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.