Closed johnsimons closed 11 years ago
can we just clear up one point to avoid confusion
The problem is that if there is a configuration/startup exception in the NServiceBus host, the error/stacktrace of the root exception is not shown.
the error+stacktrace of the root exception is not shown in the configured log because of an error in config. However the error+stacktrace does show up in the event log
@SimonCropp Apparently not when debugging in the IDE. I get no entry at all, let alone a stack trace.
When running without debugging, I do get 3 entries in the log, but the original stack is lost. Perhaps it's in the crash dump, but not going there :) Here are the entries:
1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Execute(System.__Canon, Magnum.StateMachine.Event, System.Object) at Magnum.StateMachine.State
1[[System.Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].RaiseEvent(System.Canon, Magnum.StateMachine.BasicEvent1<System.__Canon>, System.Object) at Magnum.StateMachine.StateMachine
1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].RaiseEvent(Magnum.StateMachine.Event)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.ServiceCoordinator.Start()
at Topshelf.Internal.Hosts.ConsoleHost.Run()
at NServiceBus.Hosting.Windows.Program.Main(System.String[])@jerrosenberg you not alone there! I have exactly the same problem, no stacktrace in event log! And I'm 100% sure this worked before! I wonder if is another v4.5 bug (I mean feature!)
@jerrosenberg i stand corrected. With the debugger i have noticed some qwerks in what gets loged in the eventlog
I think there's 2 issues here.
FailFast
seems pretty evil :)I think your solution to 1 is a good one.
Here's my opinion on why 2:
finally
blocks, finalizers, etc.If you really want this just for the event log write, then just write to the event log, and shut down gracefully, or at least not SO hard. :)
If you're worried about the event log write failing, you could always try catch that and failfast if you can't write to the log! Then I think you would definitely meet the criteria in the msdn doc:
Use the FailFast method instead of the Exit method to terminate your application if the state of your application is damaged beyond repair...
I think this methodology should be applied across the board wherever FailFast is currently used.
But I've been wrong before..
My cents.
Btw, you may enjoy this comment found here:
However, in CLR v4, Environment.FailFast when a debugger is attached gives you an MDA saying you've hit a bug in the runtime or unsafe managed code, and this is most likely caused by heap corruption or a stack imbalance from COM Interop or P/Invoke. That extremely misleading error isn't right, and we can temporarily work around this by using Environment.Exit if a debugger is attached. The right fix is to plumb FailFast correctly through our native Watson code, adding in a TypeOfReportedError for fatal managed errors.
note: perhaps try catch from the code that calls topshelf and re-throw a new aggregate exception to preserve stack trace
@johnsimons @andreasohlund proposed fix here https://github.com/NServiceBus/NServiceBus/commit/d1c2203442e44da742f6e55480ef668319c1b85a
the Idea is to
thoughts?
How do u find such obscure Apis? It feels like voodoo!
The only thing I don't like is the public extension method on the Exception class that we do not own :(
On Tuesday, June 18, 2013, Simon Cropp wrote:
@johnsimons https://github.com/johnsimons @andreasohlundhttps://github.com/andreasohlundproposed fix here d1c2203https://github.com/NServiceBus/NServiceBus/commit/d1c2203442e44da742f6e55480ef668319c1b85a
the Idea is to
- catch the topshelf exception
- extract the inner exception
- patch the stack trace of the inner exception
- rethrow the inner exception
- let the runtime handle it as an unhandled exception
thoughts?
— Reply to this email directly or view it on GitHubhttps://github.com/NServiceBus/NServiceBus/issues/1137#issuecomment-19605989 .
Regards John Simons NServiceBus
Fair point. I will make it internal.
As for the voodoo... There are other ways of doing it but they involve reflection.
Also we can remove the voodoo when we move to 4.5 since there is a simplified public api in 4.5
So what does the exception look like? Can u show a before and after?
On Tuesday, June 18, 2013, Simon Cropp wrote:
Fair point. I will make it internal.
As for the voodoo... There are other ways of doing it but they involve reflection.
Also we can remove the voodoo when we move to 4.5 since there is a simplified public api in 4.5
— Reply to this email directly or view it on GitHubhttps://github.com/NServiceBus/NServiceBus/issues/1137#issuecomment-19607530 .
Regards John Simons NServiceBus
Have a look at the unit test I added
Looks good, add a comment /YT to get rid of it when we are 4.5 only
On Tue, Jun 18, 2013 at 2:32 PM, Simon Cropp notifications@github.comwrote:
Have a look at the unit test I added
— Reply to this email directly or view it on GitHubhttps://github.com/NServiceBus/NServiceBus/issues/1137#issuecomment-19607984 .
Agree, I'll merge it in today
On Wednesday, June 19, 2013, Andreas Öhlund wrote:
Looks good, add a comment /YT to get rid of it when we are 4.5 only
On Tue, Jun 18, 2013 at 2:32 PM, Simon Cropp <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>>wrote:
Have a look at the unit test I added
— Reply to this email directly or view it on GitHub< https://github.com/NServiceBus/NServiceBus/issues/1137#issuecomment-19607984>
.
http://andreasohlund.net http://twitter.com/andreasohlund
— Reply to this email directly or view it on GitHubhttps://github.com/NServiceBus/NServiceBus/issues/1137#issuecomment-19638195 .
Regards John Simons NServiceBus
This issue was raised on the mailing list, see http://tech.groups.yahoo.com/group/nservicebus/message/18755
The problem is that if there is a configuration/startup exception in the NServiceBus host, the error/stacktrace of the root exception is not shown.
The code that is problematic is this (copied here for convenience):
The problem is we assume that
LogManager
has already been configured but that may not be correct because for example:What would be the state of the logger?
To address this issue I recommend we do a
Console.Out
as well. So the code would end up like:The
Environment.FailFast
is still required because it logs to the Event Viewer as a backup in case neither of the above worked.