StackOverflowException on Windows Server 2003 Enterprise Edition Service Pack 2 - c#

I have built a standalone console app that is throwing intermittent StackOverFlow exceptions only when installed on a Windows Server 2003 Enterprise Edition Service Pack 2 test machine. The code is far too complex to post, but here are the details:
Source code is C# VS 2010.
There are no recursive calls in the source code, but it does use a worker thread.
The running process is not terminated when the StackOverflowException occurs.
When the exception occurs, it will consistently occur in the same location.
When the exception occurs, it almost always occurs when the code is trying to initialize across a COM boundary i.e: CAsset asset = new CAsset() where CAsset is a COM object written in C++.
Replacing the direct initialization with a call to System.Activator.CreateInstance
System.Type assetType = System.Type.GetTypeFromProgID("GDMTCommon.HansenAsset");
object activated = System.Activator.CreateInstance(assetType);
asset = activated as CHansenAsset;
does not solve the problem, but it does move the point of failure to a different location in the code. Also the above code does not throw an error, but the asset variable is null after the direct cast. This instance is the one time that the failure does not occur on initializing a COM object.
The most baffling behavior is that I can run the tool on two different sets of source data on the test machine, and for one set of source data the code will run to completion without error, on the other the code fails.
I have installed the same tool on two different Windows 7 test machines and could not reproduce the error on either machine. I also installed the tool on a Windows Server 2003 Standard Edition Service Pack 2 test machine and could not reproduce the error on that machine.
Numerous searches have turned up a couple of other questions where code working on one OS starts throwing StackOverflowExceptions on when installed on Windows Server 2003 , but I did not see any definitive solutions.
I found this knowledge base article that seems to describe my problem:
http://support.microsoft.com/kb/915750
But according to the article, the problem is fixed in Service Pack 2 and I have verified that Service Pack 2 is installed on the test machine.
Any assistance will be greatly appreciated.
Regards,
Jay

Running Windows Update and applying all of the available updates to the machine resolved the stack overflow problems. Still unsure what was causing them in the first place. Since this was a client machine that I did not have access to, I had to wait for them to apply the updates.

Related

Running a workflow within another workflow - Both terminates

I have been using windows workflow foundation and calling a workflow from another workflow.
Using .Net framework 4.6.1 along with MS SQL Server 2014. The whole scenario is working absolutely fine.
However, when I deploy it to a customer environment it starts terminating without an exception or log trace. I have added detail logging (printing log statements on different lines) but it terminates on different statements.
As debugging in customer environment is not a good idea, any pointers in identification of this issue would be appreciated.

Azure Cloud Service Startup Task that requires reboot

Tried with osFamily 4, osVersion *
Background: we have an app that uses System.Management.Automation.dll (from the GAC, dev box is W10) to work with Powershell in C# code. Specifically, we are using InitialSessionState and the ExecutionPolicy property - which we found out is part of WMF 5 (it errors out with not found exception on type load on the cloud service).
Now, this can be properly fixed by installing WMF 5 (we tried first via Remote Desktop; and no, forcing only the newer s.m.a.dll into the GAC does not work). Problem is, the installer asks for a reboot - and that I think is a problem with the startup task.
We added the installer to the setup.cmd that we already had:
Win8.1AndW2K12R2-KB3134758-x64.msu /quiet
It indeed automatically reboots the role instance, and runs setup.cmd again (which adds an error entry to the setup event log to the tune that it is already installed).
This reboot does not flag the cloud service deployment as failed. Which we are happy about but, is this really a supported behavior? or accidental?
Is there the supported way to make an installer work that requires a reboot? Or is the behavior we found the "supported" way?
There's not really a "supported" way - how you initialize your cloud service is really up to you. Having said that:
Given that cloud service role instances typically survive reboots, there's nothing wrong with setting something up that requires a reboot. Then it's a matter of dealing with already-installed software when returning from the reboot (e.g. leaving a breadcrumb file from your .cmd that installed the software initially). This is sometimes the only way you can install software (where reboots are involved), and utilizing a breadcrumb helps cut down on subsequent reboot time (the clock-time required to complete the boot process; not the number of actual reboots).
In this type of scenario, only the initial role instance boot has an additional reboot. (other reboots, from Guest OS and Host OS updates, or failed hardware etc., are separate, of course).

Does the system record the exception when a .NET service fails?

I have a .NET4/C# based windows service running on Windows Server 2008 R2 x64. Rarely it crashes and none of the catch blocks get triggered (they are in all root methods). I would like to know why.
Does the system record somewhere the error that it fails with?
I think you should be able to see something in EventViewer->Windows Logs. Here you can find which kind of data EventViewer is tracking:
http://windows.microsoft.com/en-us/windows/what-information-event-logs-event-viewer#1TC=windows-7

How to debug a C# service that stops for no reason on production server

We have implemented a pair of services in C# that send and receive faxes. These services have been running flawlessly for several years on several servers - until last week.
One of our clients upgraded to Windows Server 2012. We installed the services and all hellbroke loose.
Basically, one of the services appears to work for several minutes, and then, for some unknown reason - goes to the OnStop method. So someone, or something - is stopping it, but I don't know what it is.
How could I go about debugging this? I am new to C# and this is not my code.
Any help would be appreciated.
Is interesting the fact you are sending and receiving faxes: It colud be related to some Session 0 Insolation introduced with windows server 2008/2012, that could cause problem in graphic related services.
If you have some chanches to run the server on a developement machine, using a Windows7/8 box and a SYSTEM user, you can probably reproduce the problem.
If it only stops on the production server, it is reasonable that there is something different about the production server than your development server/workstation.
It is probably unlikely that you're allowed to hook a debugger into something on the production server, but the best way to handle this is just to log the he** out of the code.
You should introduce enough logging to figure out:
Where it stops
Why it stops (my money is on an exception)
The state of the application at that time (related to the crash)
This will probably have to be done in iterations, unless you go all out to begin with.
Services and logging go hand in hand, so just implement it.

Access To Message Queue System Denied Windows 7 Reading Windows 2003 - Windows 2008

I have an application that reads/writes from/to message queues on remote application servers. The clients usually run on machines outside of the servers' domains/forests with no trust setup.
In Windows XP this was no problem, but with the introduction of Windows 7 it stopped working.
After some research I found the suggested Registry tweak for the server (the NewRemoteReadServerAllowNoneSecurityClient DWORD in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSMQ\Parameters\Security fix) and implemented that, but the software still throws an exception that access was denied to the Message Queuing system.
The message queuing system on our test server is wide open, with full control for both the EVERYONE and ANONYMOUS LOGIN accounts.
What am I missing?
I've been dealing with Microsoft support for a little over a week and they have confirmed that this is a bug in Windows 7 and in Windows Server 2008. I'll come back and add more details about when they expect a fix or workaround when I have that information, but for the time-being it appears that this is simply a bug and unworkable.
Try these blog posts:
http://blogs.msdn.com/b/johnbreakwell/archive/2010/03/24/understanding-how-msmq-security-blocks-rpc-traffic.aspx
http://blogs.msdn.com/b/johnbreakwell/archive/2008/06/27/cross-forest-msmq-you-need-to-be-trusting.aspx
http://blogs.msdn.com/b/johnbreakwell/archive/2008/04/29/clear-the-way-msmq-coming-through.aspx
http://blogs.msdn.com/b/johnbreakwell/archive/2008/02/14/how-do-i-send-msmq-messages-between-domains.aspx
Cheers
John Breakwell
Plumbersmate.EU
Could you clarify if you are having problems sending or receiving?
Sending and receiving use different network protocols and problems are resolved with completely different approaches.
As you mention that the application throws an exception then I will assume you get Access Denied on Remote Read operations only.
It sounds like the NewRemoteReadServerAllowNoneSecurityClient problem. You wrote "Thus far I've added the necessary DWORD key/values in the registry, rebooted the server," - which machine(s) did you change the setting on?
Cheers
John Breakwell

Categories

Resources