bitwarden / desktop

The desktop vault (Windows, macOS, & Linux).
https://bitwarden.com
GNU General Public License v3.0
3.54k stars 401 forks source link

Desktop v1.20 crashes with JavaScript error on Windows after update #495

Closed pnepus closed 4 years ago

pnepus commented 4 years ago

Exception / Crash

Error: The specified module could not be found.
\?\C:\Users\Frodo\AppData\Local\Temp\4a2f6f06-7c8b-4661-8fcf-43ab2cd758f6.tmp.node
   at process.func (electron/js2c/asar.js:138:31)
   at process.func [as dlopen] (electron/js2c/asar.js:138:31)
   at Object.Module._extensions..node (internal/modules/cjs/loader.js:828:18)
   at Object.func (electron/js2c/asar.js:138:31)
   at Object.func [as .node] (electron/js2c/asar.js:147:18)
   at Module.load (internal/modules/cjs/loader.js:645:32)
   at Function.Module._load (internal/modules/cjs/loader.js:560:12)
   at Module.require (internal/modules/cjs/loader.js:685:19)
   at require (internal/modules/cjs/helpers.js:16:16)
   at Object. (C:\Program Files\Bitwarden\resources\app.asar\node_modules@nodert-win10-rs4\windows.security.credentials.ui\lib\main.js:25:20)

Environment

Screenshots or Videos

Crash Error image

Workaround

  1. Go to https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads and download the appropriate version (for your machine architecture) of the Visual C++ redistributable package for Visual Studio 2015, 2017 and 2019 latest update (listed here for convienience):
  2. Install/run that package.
  3. Reboot
  4. Run Bitwarden, it should be working.

Root Cause Analysis

There appears to be downstream dependencies of NodeRT, specifically the @nodert-win10-rs4\windows.security.credentials.ui module, which rely on assemblies/DLLs from the VC++ Build Tools for Visual Studio 2015-2019. These dependencies are generally on a fair amount of Windows computers, including most Windows 10 installs, however this is not consistent and the module is not pulling in those necessary assemblies in its dependency chain during the electron-builder build phase or packaging phase for distribution.

pnepus commented 4 years ago

run from admin not helping

bauk commented 4 years ago

Same here, Windows 10.

EvgeniyDoctor commented 4 years ago

I got the same error, win 7.

sriatom commented 4 years ago

same error on windows 10, 2004. Tried to uninstall, reboot and reinstall but the issue continues

cscharf commented 4 years ago

We're still working on this issue and trying to setup appropriate environments, debug symbols for electron, NAN, NodeRT, etc. Thanks for your patience as we try to get this resolved.

bauk commented 4 years ago

I appreciate it! Using the web vault in the mean time. Any other information I/we can provide?

cscharf commented 4 years ago

yes, actually...

We've narrowed down the issue with added dependencies regarding the Windows Hello APIs we're accessing from the app to integrate biometrics for Windows users. These work on most systems but there appears to be a missing dependency/module error for others.

If anyone is interested in giving something like DependencyWalker, etc. a try to help determine which missing DLL(s) there may be where we're not able to narrow down in our own dependency graphs that would be huge. In the meantime we're still working on it (although we're not able to reproduce it).

sriatom commented 4 years ago

@cscharf i have 3 Windows 10, all of them are on 2004 - 2 virtual and 1 physical. It failed on Physical but succeeded on others. After the install is completed, I normally uncheck "start bitwarden" post install. When I did that, the installer hung for a bit and the application never started (physical).I tried to reproduce but it worked in 2 other desktops i have.

cscharf commented 4 years ago

Thanks, I also only have VMs to run Windows in, getting my version up to 2004 now for testing just in case I can reproduce it. I'm wondering if it's a driver difference/version between VM and physical hardware since this API can deal with biometric input devices.

tgreer-bw commented 4 years ago

Looks like it's this DLL causing the issue. It should be in /system32 for windows users.

When renaming/removing this file we can reproduce the issue:

capture

If anyone would like to try and drop this file into their environment to confirm it fixes their issue - please do.

vccorlib140.dll.zip

cscharf commented 4 years ago

It can also be copied into your %PROGRAMFILES%\Bitwarden\ directory if you don't want to modify your System32 directory (which I personally wouldn't ;-)

glimmerwell commented 4 years ago

So I have Win 7. I have actively avoided as much Microsoft connection as possible, running programs to turn off MS telemetry, etc. I was installing the Windows "Security only" updates for example. So I would not want the Hello stuff.

cscharf commented 4 years ago

That's fair @glimmerwell , and honestly don't blame you to some degree, however electron side-loads the necessary DLLs and APIs at runtime packaged with the application and that package is necessary to enable the use of Windows Hello, even if not enabled. The DLL being added to the application directory ensures it's only loaded by Bitwarden (vs. in a system directory) and if you don't enable Windows Hello settings in Bitwarden, the APIs there other than init won't be accessed, and can remain turned off/disabled in Windows itself.

I'll circle back with the team and see if we have a clean way to test that to be sure, perhaps using sysinternals to measure system access through that DLL and corresponding APIs

glimmerwell commented 4 years ago

Thanks! Let us know what you come up with.

cscharf commented 4 years ago

FYI, relates strongly to (and same RCA as): https://github.com/NodeRT/NodeRT/issues/87

ElectricVehicle commented 4 years ago

Windows 7 Home Premium Service Pack 1, FYI: I'm getting the same error:

[Window Title] Error

[Main Instruction] A JavaScript error occurred in the main process

[Content] Uncaught Exception: Error: The specified module could not be found. \?\C:\Users\Frodo\AppData\Local\Temp[funny hex digits omitted].tmp.node at process.func (electron/js2c/asar.js:138:31) at process.func [as dlopen] (electron/js2c/asar.js:138:31) at Object.Module._extensions..node (internal/modules/cjs/loader.js:828:18) at Object.func (electron/js2c/asar.js:138:31) at Object.func [as .node] (electron/js2c/asar.js:147:18) at Module.load (internal/modules/cjs/loader.js:645:32) at Function.Module._load (internal/modules/cjs/loader.js:560:12) at Module.require (internal/modules/cjs/loader.js:685:19) at require (internal/modules/cjs/helpers.js:16:16) at Object. (C:\Program Files\Bitwarden\resources\app.asar\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\lib\main.js:25:20)

[OK]

Captured this using the trick where you type ctrl-C while the dialog box has focus to capture the text. Sure beats transcribing it by hand when you want to cut and paste the info, file paths, etc.

It's a great laptop, staying on Windows 7 that limits RAM, etc. but better than the later Windows versions that started sharing your WiFi password with people who may not be your friends and forcing similar evil functionality into "updates". So this system has minimal updates. Someday, I'll move to Windows 10, but updates for Win10 are breaking some apps.

cscharf commented 4 years ago

Thanks @ElectricVehicle , and thank you for the plain text version as well. Can you please download this DLL (vccorlib140.dll.zip), unzip and copy it to your installation directory for Bitwarden and try re-opening the application to see if that resolves your issue?

glimmerwell commented 4 years ago

So this is not working for me. I still can't get it to run. I uninstalled, rebooted, ran the installer as admin. Doesn't work...

cscharf commented 4 years ago

@glimmerwell , did you copy that DLL to the application directory?

cscharf commented 4 years ago

We've not had a chance to publish the new version yet

cscharf commented 4 years ago

Reopening this issue for now until we can get a new version published to the Microsoft Store and website. In the meantime you may use the workaround noted in this issue description above to resolve the issue.

ElectricVehicle commented 4 years ago

@cscharf - I downloaded, extracted and copied vccorlib140.dll to C:\Program Files\Bitwarden where my BitWarden is installed. I'm still getting the error. Next step?

Then I noticed I have 6 Bitwarden.exe processes running, even though I've dismissed the error dialog and there are no active BitWarden dialogs or windows. The processes are only visible in task manager.

I manually ended all the Bitwarden.exe processes, ran BitWarden again and still got the error.

After I dismiss the error dialog the 2 Bitwarden.exe processes still running, even though I've dismissed the error dialog and there are no active BitWarden dialogs or windows. The processes are only visible in task manager.

[Window Title] Error

[Main Instruction] A JavaScript error occurred in the main process

[Content] Uncaught Exception: Error: The specified module could not be found. \?\C:\Users\Frodo\AppData\Local\Temp[funny hex digits omitted].tmp.node at process.func (electron/js2c/asar.js:138:31) at process.func [as dlopen] (electron/js2c/asar.js:138:31) at Object.Module._extensions..node (internal/modules/cjs/loader.js:828:18) at Object.func (electron/js2c/asar.js:138:31) at Object.func [as .node] (electron/js2c/asar.js:147:18) at Module.load (internal/modules/cjs/loader.js:645:32) at Function.Module._load (internal/modules/cjs/loader.js:560:12) at Module.require (internal/modules/cjs/loader.js:685:19) at require (internal/modules/cjs/helpers.js:16:16) at Object. (C:\Program Files\Bitwarden\resources\app.asar\node_modules\@nodert-win10-rs4\windows.security.credentials.ui\lib\main.js:25:20)

[OK]

cscharf commented 4 years ago

Thanks @ElectricVehicle , investigating further.

glimmerwell commented 4 years ago

Unfortunately, now I am getting errors with my email client not connecting (not sure if that is related). And gotta leave for several hours. Will get back to you. Yes, I tried putting the dll in there and it didn't work. So I uninstalled, rebooted, tried to install as admin, got error message.

Will get back to you guys. Sorry!

cscharf commented 4 years ago

Would either of you be able/willing to run Dependencies to try to determine where the missing DLL may be? Either that or sysinternals process explorer may be able to give you the file load miss and failure operations to determine what DLL is attempting to be loaded that doesn't exist on your system. One of those 2 things I think would be the absolute most beneficial at the moment.

The only way were able to reproduce this error was removing that DLL from our system (renamed it with .old so it led us to believe that would resolve the problem as well (having it in the application directory).

ElectricVehicle commented 4 years ago

@cscharf - I was about to copy vccorlib140.dll to C:\Windows\System32, but I stopped when I noticed there was already a version there.

I already have a pre-existing copy of vccorlib140.dll in C:\Windows\System32 . The file properties of th existing vccorlib140.dll are: File description: Microsoft VC WinRT core library Size: 377 KB (386,712 bytes) File Version: 14.13.26020.0 Product Name: Microsoft Visual Studio 2017 Product version: 14.13.26020.0 Date modified: 12/19/2017 9:50 PM

The vccorlib140.dll that's listed above fo download I put in C:\Program Files\Bitwarden properties are: File description: Microsoft VC WinRT core library Size: 329 KB (337,392 bytes) File Version: 14.26.28720.3 Product Name: Microsoft Visual Studio Product version: 14.26.28720.3 Date modified: 7/30/2020 2:30 PM (likely the modified time from Microsoft did not get preserved.)

I'll try and run Dependencies and/or sysinternals process explorer to debug further. This may be a case of "These aren't the DLLs (Droids) you're looking for". It may be finding a version of the DLL that doesn't support the interface.

laurencethompson commented 4 years ago

Windows 7 Pro on Dell desktop

Copied the dll into Bitwarden's directory - still had the issue.

Ran Dependancies - it shows some dlls having missing imports and a few missing completely

These are the missing ones

2020-07-31 10_46_11-Dependencies (x64)

cscharf commented 4 years ago

@laurencethompson, I would believe the **-core-winrt-** libraries could be the culprit, but that are supposed to be installed on Windows 7 sp1+ and 10. Unfortunately Dependencies doesn't support api set schema redirection completely so those DLLs may not be missing or may just have downstream dependencies or corrupt/missing COM+ containers, etc. Are you able to run SysInternals Process Monitor when executing Bitwarden and provide a trimmed trace for file access? I can provide an email address if you wanted to share via a private/secure means (var domain = "bitwarden.com"; return "c" + "scharf" + "@" + domain;)

ElectricVehicle commented 4 years ago

@cscharf - I get this dialog from Dependencies as I'm loading Bitwarden.exe .

Dependencies (x64): DependenciesGui.exe - Entry Point Not Found

The procedure entry point _o_memset could not be located in the dynamic link library api-ms-win-crt-private-l1-1-0.dll.

OK

I click Ok and Dependencies finishes loading Bitwarden.exe .

BitwardenDependenciesScreen1

BitwardenDependenciesScreen2

ElectricVehicle commented 4 years ago

@cscharf - Oddly, the processor architecture is showing AMD, but this is an Intel Core i7-3610QM processor. C:\Users\Frodo>set .... PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 58 Stepping 9, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=3a09

In Dependencies the DLL detail shows AMD on my Intel Core i7-3610QM processor. BitwardenDependenciesDllDetailShowsAmdOnIntelComputer

cscharf commented 4 years ago

yeah, that makes sense, all 64-bit x86 processors use the AMD 64-bit architecture. Intel licenses it from AMD (hence the name).

As far as the missing api-ms-win-core-winrt-11-1-0.dll, etc. those are API sets which are higher-level indirection DLLs in Windows and there's not much else Dependencies can do with them, :-/

ElectricVehicle commented 4 years ago

Anything else I can do to help - should I run the SysInternals Process Monitor?

cscharf commented 4 years ago

Yes, that process monitor would be a huge help I think, that should reveal the underlying access failures for any DLLs that are attempting to be loaded through those indirection pointers, which should give us the specific method/API and DLL that houses it.

cscharf commented 4 years ago

After running SysInternals Process Monitor (or if anyone else wants to try this in the meantime)

I believe one of us had to install the VS 2015 C++ Build Tools in order to get the build working on their Windows machine, but it work(ed/s) just fine on mine and the build agent (Mac and Linux respectively), I do wonder, albeit that's a common redistributable package for a lot of applications on Windows, not everyone would have it and electron-builder doesn't package it in the installer/detect it's needed like other compiled MSIs might, etc.

If someone who is experiencing this issue could try installing the VC++ Redistributable Package for VS 2015 to 2019, I think that may solve the problem. You should not need to uninstall/reinstall Bitwarden, but you may need to reboot after installing this. If that does solve the problem, I'll work on getting it packaged with our installer and listed on the necessary pre-requisites for running our portable executable.

Thank you again everyone for your help and patience in getting this figured out; it's much appreciated.

cscharf commented 4 years ago

I just uninstalled the VC++ Redistributable package for VS 2015 to 2019, attempted to run Bitwarden on my Windows 10 VM, and was able to reproduce the error/issue. After re-installing from the download location in my prior comments (updated), https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads, I was able to successfully launch Bitwarden again w/o issue.

PelQel commented 4 years ago

I had received this error as well after the latest update... and was in a panic searching all over for a fix when I found this thread...

Running OS: 8.1 Home. Sorry, I didn't keep a screenshot...

Installed the VS 2015, 2017, 2019 as suggested, as well as the latest update for x64.... just wanted to say THANK YOU SO MUCH to everyone who located the issue and offered a fix! Opened and working fine again for me!

jbjknt commented 4 years ago

On Win7 Home Premium and installed the VC++ Redistributable Package for VS 2015 to 2019, rebooted and tried starting Bitwarden again but received the same JavaScript error. Tired reinstalling Bitwarden-Installer-1.20.0.exe and rebooted but still the same error. Seems the workaround may work on Win10 only.

SleepingCat-05 commented 4 years ago

bonjour, J'ai trouvé une solution pour contourner ce problème. J'ai désinstallé la version 1.20, installé la version 1.19, décoché "Lancer Bitwarden", ensuite, j'ai été dans "programmes -> Bitwarden -> ressources" et l'ai renommé app-update.yml en old-app-update.yml, ce qui empeche le lancement de la mise à jour automatique. Je continue à travailler avec la version 1.19 en attendant un patch. Cordialement (désolé mais mon anglais est très moyen, je passe donc par google translate). Stéphane

Hello, I have found a solution to work around this problem. I uninstalled version 1.20, installed version 1.19, unchecked "Launch Bitwarden", then I went to "programs -> Bitwarden -> resources" and renamed it app-update.yml to old-app-update.yml, which prevents the automatic update from starting. I continue to work with version 1.19 while waiting for a patch. cordially (sorry but my english is very average so I go through google translate). Stephane

PelQel commented 4 years ago

On Win7 Home Premium and installed the VC++ Redistributable Package for VS 2015 to 2019, rebooted and tried starting Bitwarden again but received the same JavaScript error. Tired reinstalling Bitwarden-Installer-1.20.0.exe and rebooted but still the same error. Seems the workaround may work on Win10 only.

@jbjknt I believe that you ALSO have to install the latest VS update for your environment (either x64 or x86) located on the first page - after installing VS-2015-19. It didn't work for me either until after the update was also installed.

cscharf commented 4 years ago

@PelQel, thank you, that's a valid statement, from that download page I had simply clicked directly on the update below the first link provided.

With that, I'll add the clarification here (install one of these based on your machine's architecture):

ElectricVehicle commented 4 years ago

A bit of googling gave me some ideas that I have not yet tried. I'm posting them in case they're useful.

Install the latest Visual Studio runtimes "Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019" and then reboot. The reboot is required to force the shared DLL in memory to reload.

This should update vccorlib140.dll in C:\Windows\system32\ to a version after April 2018 that includes support for Windows Hello.

Assorted details:

From the error message, NodeRT is trying to use "@nodert-win10-rs4\windows.security.credentials.ui" The "rs4" is the April 2018 Update (Redstone 4) Windows 10 release. I assume VC++ reditributables linked above that are after the April 2018 date should have the updated vccorlib140.dll

SDK: Windows 10, Build 17134 Known As: April 2018 Update (Redstone 4) Windows Version: 1803 npm Scope: npmjs.com/org/nodert-win10-rs4

The api "windows.security.credentials.ui" is part of the UWP (Universal Windows Platform). Based on the file description property of vccorlib140.dll (File description: Microsoft VC WinRT core library) and the winrt with version 1734 ("?view=winrt-17134") in the URL for the namespace documentation, I believe vccorlib140.dll for Windows 10, Build 17134 implements "windows.security.credentials.ui". Windows / Apps / UWP / Reference / Windows Runtime API / Windows.Security.Credentials.UI Windows.Security.Credentials.UI Namespace

When an app loads, if the DLL name it requires is already loaded in memory, it will use the copy in memory and will not do a DLL search.

This Microsoft tool might be interesting, even though you're not going for certification, it might show DLL version issues for various Windows versions? I'm not set up to run it, so I haven't tried it. UWP Windows-10 WACK tests Errors Windows App Certification Kit (WACK)

cscharf commented 4 years ago

Got a Sysinternals Process Monitor dump and after analysis, it looks like the following DLLs (as part of the higher-level Windows API Redirection DLL pointers) are what's necessary:

The issue here, at this juncture, is that the reference is ignoring local copies of these and instead referencing the higher level redirection DLLs (which you can't and shouldn't package with an application); these are not physical DLLs but Windows API redirection to core system DLLs or redistributable packages (like in this case); so there's no way we can package copies of these in our app installer or portable version directly because they are ignored (at least in Windows 10).

I will try to setup a Windows 7 VM to test whether it would alleviate that at least, but would rather have a universal solution.

BTW, WACK testing came back generally okay, there were some false-negatives with the setup/deployment tools embedded in asar, etc. wack-cert-test-bitwarden.zip

glimmerwell commented 4 years ago

HI, I am back and have caught up on this thread.

I tried SleepingCat-05's idea above (Thanks!). It is a successful temporary work around for those that just need to get rolling right now. But remember it will be broken for updates and you will need to remember to go back in later and undo it once this problem is resolved.

To restate SleepingCat-05's excellent description, you uninstall 1.20.0, then install 1.19.0, uncheck "Launch Bitwarden"in the installer, then go into the Bitwarden install resources sub-directory/folder (in my case: C:\Program Files\Bitwarden\resources), then rename app-update.yml to something else (I chose app-update.yml.old). Bitwarden Desktop seems to work now.

This doesn't help fix the problem though so I am willing to continue.

Now, are you saying future Bitwarden Desktop installs will require us to install more Microsoft updates so you can get Hello working for some users?

glimmerwell commented 4 years ago

Oh, to add to my last post for the work around, I went into Task Manager and made sure the Bitwarden processes weren't here. Since I had rebooted they weren't. I also first went into C:\Users\Your User Name\AppData\Local\bitwarden-updater and renamed it as well. I wasn't sure so I did it as a precaution. Its probably not necessary.

Oh, I did not run the .exe as an administrator, for better or for worse.

sriatom commented 4 years ago

@glimmerwell solution worked for me as well. i am on 1.19 for now

ElectricVehicle commented 4 years ago

A little more on the DLL search order. Basically it boils down to, if there's a version of the DLL in the SystemDirectory (typically C:\Window\System32), that's the one that's going to be used if another application has already caused the DLL to be loaded. So for any DLL that might be in the SystemDirectory , that one needs to be updated and not store it in the application directory.

Otherwise, you might get the SystemDirectory version of the DLL or the one in your app directory. Even if no other app currently loads the version in the SystemDirectory before your app, a future app installation by the user might start using it, and then your app mysteriously breaks.

Factors That Affect Searching

DLL Hell!

I think I'm going to install the "Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019", reboot and see what happens on my Windows 7 Home Premium Service Pack 1 computer.

glimmerwell commented 4 years ago

Cool! Let us know...

kspearrin commented 4 years ago

Here's a potential fix @cscharf recently built. Could any of you try this and see if it works? https://cdn.bitwarden.com/misc/Bitwarden-Portable-1.20.0.exe.zip

ElectricVehicle commented 4 years ago

Extracting the zip and opening Bitwarden-Portable-1.20.0.exe from the custom build linked above works on my Windows 7 Home Premium Service Pack 1 computer. The production 1.20.1 is not working on my computer. I have not done the "Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019" install yet. So this confirms the custom build work vs. the production build on my computer. FYI - I didn't see anything on the login screen about Windows Hello being available or not. I don't know if that's expected behavior or not. Anyway, FYI. Thanks!

laurencethompson commented 4 years ago

Here's a potential fix @cscharf recently built. Could any of you try this and see if it works? https://cdn.bitwarden.com/misc/Bitwarden-Portable-1.20.0.exe.zip

I can confirm that this works on my Win 7 Pro SP1 desktop.

The release version does not work.

I do have the VC Redistributable installed.