question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

w3wp.exe halted with unhandled exception after reboot

See original GitHub issue

Describe the bug

After starting my machine, all w3wp.exe processes for my ASP.NET Core applications were terminated due to an unhandled exception.

To Reproduce

I did not reproduce it yet, but I could attach a debugger to one of the w3wp.exe processes and isolate the following info:


// in AspNetCoreModuleV2\InProcessRequestHandler\inprocessapplication.cpp, line 190:

void IN_PROCESS_APPLICATION::ExecuteApplication()
{
// ...
// Line 274: 

	bool clrThreadExited;
	{
		auto redirectionOutput = LoggingHelpers::CreateOutputs(
						m_pConfig->QueryStdoutLogEnabled(),
						m_pConfig->QueryStdoutLogFile(),
						QueryApplicationPhysicalPath(),
						m_stringRedirectionOutput
				);
				// ...
				// Exception thrown at the end of this scope, when destructor of redirectionOutput 
				// calls d'tor of FileRedirectionOutput for stdout.log
	}

// There, in AspNetCoreModuleV2\CommonLib\RedirectionOutput.cpp, line 85:

FileRedirectionOutput::~FileRedirectionOutput()
{
	if (m_file.is_open())
	{
		// closing the stream attempts to clear the state
		m_file.close();
		//...
				
				
// then, in include\xiosbase, line 247:     

void __CLR_OR_THIS_CALL clear(iostate _State, bool _Reraise) { // set state, possibly reraise exception
	_State &= _Statmask;
	_Mystate             = _State;
	const auto _Filtered = _State & _Except;
	if (_Filtered) {
		if (_Reraise) {
		_RERAISE;
		}

		const char* _Msg;
		if (_Filtered & ios_base::badbit) {
			_Msg = "ios_base::badbit set";
		} else if (_Filtered & ios_base::failbit) {
			_Msg = "ios_base::failbit set";
		} else {
			_Msg = "ios_base::eofbit set";
		}

		_THROW(failure(_Msg));
		
		
		
// The _Msg thrown is "ios_base::failbit set";

The FileRedirectionOutput refers to the stdout log of yesterday, aspnetcore-stdout_20200817161241_724.log. This file was created, modified and accessed last time yesterday, ‎August ‎17, ‎2020, ‏‎6:12:42 PM. In the meantime, the machine has been shut down and today restarted.

Exceptions (if any)

Unhandled exception at 0x00007FFA820BDB9E (ucrtbase.dll) in w3wp.exe: Fatal program exit requested.

Further technical details

  • ASP.NET Core version

TargetFramework netcoreapp3.1 Microsoft.AspNetCore FileVersion 3.100.320.12812

  • Include the output of dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.401
 Commit:    5b6f5e5005

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.401\

Host (useful for support):
  Version: 3.1.7
  Commit:  fcfdef8d6b

.NET Core SDKs installed:
  3.1.107 [C:\Program Files\dotnet\sdk]
  3.1.401 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version VS2019 Version 16.7.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gkeongitcommented, Jun 2, 2022

After disabling the option Turn on fast startup (recommended) the error did not occur anymore. This matches my assumption that the error is caused by an invalid resume from power off status.

To change this option, go to Control Panel\Hardware and Sound\Power Options and then select Chose what the power buttons do from the left pane.

1reaction
gkeongitcommented, Jan 17, 2022

Yes, I still have an application, that runs as an auto-started Windows Service to provide a simple gRPC API. So it ‘runs’ after boot. But I have to manually restart it every morning, otherwise on first access it fails with:

Application: Tocker.API.exe
CoreCLR Version: 6.0.121.56705
.NET Version: 6.0.1
Description: The process was terminated due to an internal error in the .NET Runtime at IP 00007FFFF370D61B (00007FFFF3540000) with exit code c0000006.
Faulting application name: Tocker.API.exe, version: 1.0.0.0, time stamp: 0x61954b73
Faulting module name: coreclr.dll, version: 6.0.121.56705, time stamp: 0x619543a3
Exception code: 0xc0000006
Fault offset: 0x00000000001cd61b
Faulting process id: 0x831c
Faulting application start time: 0x01d80927f994fcb1
Faulting application path: D:\Projekte\cSharp\Tools\Ticker\Tocker.API\bin\Debug\net6.0\Tocker.API.exe
Faulting module path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.1\coreclr.dll
Report Id: 64f1a3d2-a7cd-4e0a-93a3-2d6734159602
Faulting package full name: 
Faulting package-relative application ID: 
Windows cannot access the file  for one of the following reasons: there is a problem with the network connection, the disk that the file is stored on, or the storage drivers installed on this computer; or the disk is missing. Windows closed the program Tocker.API because of this error.

Program: Tocker.API
File: 

The error value is listed in the Additional Data section.
User Action
1. Open the file again. This situation might be a temporary problem that corrects itself when the program runs again.
2. If the file still cannot be accessed and
	- It is on the network, your network administrator should verify that there is not a problem with the network and that the server can be contacted.
	- It is on a removable disk, for example, a floppy disk or CD-ROM, verify that the disk is fully inserted into the computer.
3. Check and repair the file system by running CHKDSK. To run CHKDSK, click Start, click Run, type CMD, and then click OK. At the command prompt, type CHKDSK /F, and then press ENTER.
4. If the problem persists, restore the file from a backup copy.
5. Determine whether other files on the same disk can be opened. If not, the disk might be damaged. If it is a hard disk, contact your administrator or computer hardware vendor for further assistance.

Additional Data
Error value: 00000000
Disk type: 0

Application is now running on net60 and is built with VS2022.

I have not installed this on different machines yet.

The log file of previous issues is on local harddisk, so nothing special there, I think.

Could this be an issue with process reactivation after a shutdown? See the Faulting application start time: 0x01d80927f994fcb1. This can be converted to 1/14/2022, 9:20:30 AM. But the corresponding event is from 1/17. In the meantime, the computer was shut down for the weekend (thus closing any opened files). If now the process gets reactivated only (not restarted), it might refer to an invalid ‘open file’?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot application pool crashes on Cloud Services
Step 5: Check for unhandled exceptions in the w3wp.exe or WaWorkerHost.exe process. To also check for any unhandled exceptions that caused the  ......
Read more >
Net Framework: exception in w3wp.exe
It was caused by updates of .Net Framework 4.5. I uninstalled last update. It solved the problem. Tip: How to check event viewer....
Read more >
An unhandled win32 exception occurred in w3wp.exe IIS ...
Find answers to An unhandled win32 exception occurred in w3wp.exe IIS Worker ... when error happen this website app pool will be rebooted....
Read more >
An unhandled Microsoft .Net Framework exception occurred in ...
Open it, go to the Details tab, find the w3wp.exe process by process ID and run the “Create dump file” command with a...
Read more >
Cannot login in Smart Client and Management Client because ...
Cannot login in Smart Client and Management Client because w3wp process crashes with unhandled .NET exception every day and leads to w3wp service...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found