Silverlight 5 - Debugging npctrl.dll crash

2020-02-26 06:29发布

问题:

I'm getting a really frustrating silverlight plugin crash which affects both IE and firefox.

The error from the event log is:

Faulting application name: iexplore.exe, version: 9.0.8112.16421, time stamp: 0x4d76255d
Faulting module name: npctrl.dll, version: 5.0.61118.0, time stamp: 0x4ec5fc64
Exception code: 0xc0000094
Fault offset: 0x0001d720
Faulting process id: 0x434
Faulting application start time: 0x01ccf0b878b55ca7
Faulting application path: C:\Program Files (x86)\Internet Explorer\iexplore.exe
Faulting module path: c:\Program Files (x86)\Microsoft Silverlight\5.0.61118.0\npctrl.dll
Report Id: bd79af3d-5cab-11e1-8948-000c29de3e25

I've gotten as far as attaching WinDbg during the exception to get a little bit more information:

(17e4.13f8): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Windows\SYSTEM32\ntdll.dll - 
ntdll!DbgBreakPoint:
00000000`77810530 cc              int     3
0:029> g
(17e4.1790): Integer divide-by-zero - code c0000094 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for NPCTRL.dll     - 
NPCTRL+0x1d720:
7b59d720 f7f1            div     eax,ecx

Ok, so ntdll.dll is dividing by zero. I really have no idea how I can debug further. I've tried viewing some of the articles which explain how - but I think I'm limited based on the fact that there are no symbols available for ntdll.dll?

How can I narrow down what part of my code is leading to this error?

回答1:

After hours of debugging, I was able to replicate the problem in a small project. Just create a 'silverlight enabled web service', and reference it. Then switch over to using the client http stack:

WebRequest.RegisterPrefix("http://", WebRequestCreator.ClientHttp);
WebRequest.RegisterPrefix("https://", WebRequestCreator.ClientHttp);

Calling the service on my machine (and a coworkers as well) has about a 10-15% chance of crashing with the ntdll.dll error.

I found two ways to mitigate this problem.

1) Stop using the client networking stack. The problem never seems to happen with the browser stack

2) Access the silverlight application outside of VMWare. The problem seems to only happen from within a virtual machine. Thanks to RobSiklos for figuring this out.

Hope this helps someone.



回答2:

Set Vmware virtual machine to use only 1 processor and problem will not reproduce. From top of the screen Virtual Machine > Virtual Machine Settings > Processors - > Number of processor cores = 1.



回答3:

Are you running inside a vmware virtual machine? See here: http://communities.vmware.com/thread/394306?tstart=0

UPDATE (2013-03-15): According to the latest post in the forum thread linked above, it seems Microsoft has finally fixed this issue.



回答4:

These Windbg commands will load the symbols for ntdll.dll (and other Microsoft modules) from Microsoft's symbol server.

.symfix

.reload /f



回答5:

If you are running the silverlight application within a virtual machine, then you can try this if you get really really desperate and need to get it working.

If you are running your silverlight application and the data provider in the same web site or same process, try splitting them. Let me explain...

My application had 3 options, (1) DIRECT DATABASE CONNECTION (not applicable here), (2) WEB SERVICE or (3) HTTP aspx page.

Whenever I used options 2 and 3 but called the provider from within the same site, the application crashed soon. I noticed however that when I call the same (or different) web service hosted on another domain (cross-domains), then it doesn't crash.

My silverlight application relies heavily on threads running concurrently. I'm not sure if it has to do with the threads or why the w3w process and iexplore process don't work together well inside the VM.

I also got the "division by zero" error, but this was how I solved it. So, same code, same everything, except that the silverlight application and its hosted web site uses a different web site or web service as its data source (even if that data source web site was on the same virtual machine)

Does this make sense?

So S/L application running in http://localhost/app.aspx uses a WCF service running in https://itisqa-d1/folder1/service1.svc. And in this case the itisqa-d1 and localhost may or may not be the same machine, as long as they are running in seperate app domains or pools.