Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] [Windows] Unable to run Node.js in safe mode #22054

Closed
bounc3-paradise-on-e opened this issue Aug 1, 2018 · 9 comments
Closed
Labels
feature request Issues that request new features to be added to Node.js. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. windows Issues and PRs related to the Windows platform.

Comments

@bounc3-paradise-on-e
Copy link

bounc3-paradise-on-e commented Aug 1, 2018

  • Version: any
  • Platform: windows x64
  • Subsystem: runtime

Made a script for cleaning up disk and unlocking locked files. The script is written in JavaScript and intended to be run using Node.js in Windows safe mode.

When run the script in windows normal mode, it works. However, when run the script in windows safe mode, get the error:

socket: (10050) A socket operation encountered a dead network

After googling found out that windows safe mode disables network drivers and Node.js won't start if network drivers are disabled.

Is there a reason to terminate Node.js if there are no network drivers enabled? The script is supposed to use only fs and path module in order to unlink some files and rmdir directories. Network is really irrelevant and terminating the Node.js process because of missing drivers doesn't really make sense to me.

But, this is total guess, I'm not sure if missing drivers cause it or whatever, that's what I found on google and stack overflow.


To make it clear: the feature request is to allow Node.js to run in windows safe mode, without requiring any irrelevant configuration to be present (like network drivers, if that is the cause). Would like to hear your opinion.

@gireeshpunathil
Copy link
Member

IIRC I have seen couple of instances of the same but can't recollect what module is wanting to check for the network. Do you have diagnostic tools in your system to be able to capture a stack trace of the failure? the intent is to see the instigator, and make an opinion on the feasibility of the feature request based on that. thanks!

@vsemozhetbyt vsemozhetbyt added windows Issues and PRs related to the Windows platform. feature request Issues that request new features to be added to Node.js. labels Aug 1, 2018
@bounc3-paradise-on-e
Copy link
Author

bounc3-paradise-on-e commented Aug 1, 2018

Can you explain what do you mean by "diagnostic tools"? Is it a program I need to download, or is it a builtin Windows feature?

I found this link https://www.microsoft.com/en-us/download/details.aspx?id=26798
which is Microsoft DebugDiag program, labeled as "diagnostic tools". Is that what I am supposed to use? If yes, how can I configure it to dump the stack trace?

Also, forgot to mention: Node.js terminates with exit code 0x80000003

According to this page https://docs.microsoft.com/en-us/windows/desktop/wmformat/error-codes
the exit code is described as E_INVALIDARG - Invalid argument sent to a function
Seems irrelevant

@gireeshpunathil
Copy link
Member

sorry for being dumb on diagnostic tool question. While DebugDiag is one such, let me ask @nodejs/platform-windows about what is the best tool to capture the stack trace when the process terminates on a system call (socket) error.

@targos
Copy link
Member

targos commented Aug 1, 2018

So I installed WinDbg and reproduced the error. Here is what I could get:

The program stops twice, then it loops on the second "non-continuable exception".
On the first stop, the Node.js window is black. On the second stop it has the line with the socket error.

node

stack1

stack2

WinDbg log
Microsoft (R) Windows Debugger Version 10.0.17134.12 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.

CommandLine: "C:\Program Files\nodejs\node.exe"
Symbol search path is: srv*
Executable search path is: 
ModLoad: 00007ff6`51240000 00007ff6`52944000   node.exe
ModLoad: 00007ffe`19be0000 00007ffe`19dc1000   ntdll.dll
ModLoad: 00007ffe`18f10000 00007ffe`18fc2000   C:\WINDOWS\System32\KERNEL32.DLL
ModLoad: 00007ffe`16c50000 00007ffe`16ec3000   C:\WINDOWS\System32\KERNELBASE.dll
ModLoad: 00007ffe`196e0000 00007ffe`19781000   C:\WINDOWS\System32\ADVAPI32.dll
ModLoad: 00007ffd`fc800000 00007ffd`fc9c9000   C:\WINDOWS\SYSTEM32\dbghelp.dll
ModLoad: 00007ffe`16b50000 00007ffe`16c4a000   C:\WINDOWS\System32\ucrtbase.dll
ModLoad: 00007ffe`187a0000 00007ffe`1883e000   C:\WINDOWS\System32\msvcrt.dll
ModLoad: 00007ffe`18740000 00007ffe`1879b000   C:\WINDOWS\System32\sechost.dll
ModLoad: 00007ffe`195b0000 00007ffe`196d4000   C:\WINDOWS\System32\RPCRT4.dll
ModLoad: 00007ffe`17070000 00007ffe`17200000   C:\WINDOWS\System32\USER32.dll
ModLoad: 00007ffe`17050000 00007ffe`17070000   C:\WINDOWS\System32\win32u.dll
ModLoad: 00007ffe`193e0000 00007ffe`19408000   C:\WINDOWS\System32\GDI32.dll
ModLoad: 00007ffe`169b0000 00007ffe`16b42000   C:\WINDOWS\System32\gdi32full.dll
ModLoad: 00007ffe`16910000 00007ffe`169af000   C:\WINDOWS\System32\msvcp_win.dll
ModLoad: 00007ffe`154f0000 00007ffe`15528000   C:\WINDOWS\SYSTEM32\IPHLPAPI.DLL
ModLoad: 00007ffe`19b30000 00007ffe`19b38000   C:\WINDOWS\System32\PSAPI.DLL
ModLoad: 00007ffe`18fd0000 00007ffe`1903c000   C:\WINDOWS\System32\WS2_32.dll
ModLoad: 00007ffe`15df0000 00007ffe`15e18000   C:\WINDOWS\SYSTEM32\USERENV.dll
ModLoad: 00007ffe`15f90000 00007ffe`15faf000   C:\WINDOWS\System32\profapi.dll
ModLoad: 00007ffe`16720000 00007ffe`16902000   C:\WINDOWS\System32\CRYPT32.dll
ModLoad: 00007ffe`15f20000 00007ffe`15f32000   C:\WINDOWS\System32\MSASN1.dll
ModLoad: 00007ffe`139f0000 00007ffe`13a13000   C:\WINDOWS\SYSTEM32\WINMM.dll
ModLoad: 00007ffe`139c0000 00007ffe`139ea000   C:\WINDOWS\SYSTEM32\WINMMBASE.dll
ModLoad: 00007ffe`16f80000 00007ffe`16fc9000   C:\WINDOWS\System32\cfgmgr32.dll
(d30.ec0): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll - 
ntdll!LdrInitShimEngineDynamic+0x34c:
00007ffe`19cace5c cc              int     3
0:000> g
ModLoad: 00007ffe`18710000 00007ffe`1873d000   C:\WINDOWS\System32\IMM32.DLL
ModLoad: 00007ffe`15f40000 00007ffe`15f8c000   C:\WINDOWS\System32\powrprof.dll
ModLoad: 00007ffe`15770000 00007ffe`157d6000   C:\WINDOWS\system32\mswsock.dll
(d30.ec0): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\System32\KERNELBASE.dll - 
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for node.exe - 
KERNELBASE!DebugBreak+0x2:
00007ffe`16cfc902 cc              int     3
0:000> g
(d30.ec0): Security check failure or stack buffer overrun - code c0000409 (!!! second chance !!!)
node!v8::internal::interpreter::BytecodeArrayRandomIterator::UpdateOffsetFromIndex+0x306d1:
00007ff6`51e4d7a1 cd29            int     29h
0:000> g
WARNING: Continuing a non-continuable exception
(d30.ec0): Security check failure or stack buffer overrun - code c0000409 (!!! second chance !!!)
node!v8::internal::interpreter::BytecodeArrayRandomIterator::UpdateOffsetFromIndex+0x306d1:
00007ff6`51e4d7a1 cd29            int     29h
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\System32\KERNEL32.DLL - 

@antsmartian
Copy link
Contributor

antsmartian commented Aug 1, 2018

Somewhat related to this issue: nodejs/help#1240. From the comments mentioned here I guess node js requires network stack to be working properly. My hard guess is that, Safe Mode starts only with basic drivers but not with network drivers.

I don't have windows machine, but I'm sure we have option like Safe Mode with Networking, can you check if the code works in this specific mode? I guess it should do.

@bounc3-paradise-on-e
Copy link
Author

Re: targos

Thanks for doing the test. I'm not familiar with windows system calls, but I hope someone from node/windows team is able to determine how easy/hard it will be to resolve this issue based on the information you provided.

Re: antsmartian

The point of this feature request is to allow Node.js to start without network drivers. For example, network drivers may be loaded lazily in case the script uses some of the network modules (http, http2, https...), or there should be a command line option to prevent loading network drivers. If the script uses only fs and path, it seems pretty unreasonable that the network drivers are required. It sounds similar like requiring network drivers in order to start Notepad, or Paint, etc. If the program doesn't use network, loading network drivers is pointless and irrelevant.

Starting the application in safe mode with networking, though it may solve this problem (untested), it doesn't solve the general problem. What if there are no network drivers installed in the system? It will break Node.js, but, in general, if the script doesn't use network or any network modules, loading drivers should not be mandatory.

@refack refack added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Nov 11, 2018
@evgley
Copy link

evgley commented Feb 26, 2019

This behavior caused by libuv.
Fixed it here: libuv/libuv#2205

@gireeshpunathil
Copy link
Member

@bounc3-paradise-on-e - this feature is implemented through libuv/libuv#2205 , and is made available in node through #26707 which is available in v10.16.0 , v11.13.0 onwards. Can you pls check if it is working at your end and revert ? thanks.

@jasnell
Copy link
Member

jasnell commented Jun 25, 2020

It's not clear if this needs to remain open. There's been no further activity on it so I'm going to go ahead and close it but I'm adding it to the Futures project board so that it doesn't get lost

@jasnell jasnell closed this as completed Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

8 participants