18

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. Jun 27, 2012 at 0:58

5 Answers 5

Reset to default

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

18

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
4
  • 1
    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? Jun 27, 2012 at 12:46
  • 1
    @DanielLang: Yes that is also possible. Jun 27, 2012 at 14:36
  • @BryanCrosby is it possible to get a System.OutOfMemoryException and not get it logged specifically in the Appliaction section of the event viewer? Jan 10, 2017 at 13:42
  • 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. Jun 2, 2018 at 17:03
4

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

1
  • In my case, I was accidentally recursively calling a method, and this was causing a stack overflow. Jul 1 at 18:47
3

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.

1

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
  • This was also my case that the message was caused by accidental recursive loop Apr 16, 2019 at 9:30
-1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.