Repository: nvaccess/nvda

Issue:
NVDA also crashes and exits when an error occurs in the application it is interacting with
### Steps to reproduce:
1. Download Dependency Walker from [this website](https://www.dependencywalker.com/);
2. Unzip the downloaded depends22_x64.zip, and then run the depends.exe in it;
3. Press Ctrl +O to open an .exe executable.

### Actual behavior:
NVDA crashes and quits after being silent for a while

Here is the error log snippet:
ERROR - watchdog._watcher (17:28:48.876) - watchdog (1728):
Core frozen in stack!
INFO - watchdog._watcher (17:28:48.895) - watchdog (1728):
Listing stacks for Python threads:
Python stack for thread 7472 (nvwave.playWaveFile(error.wav)):

Below is the full error log:
[nvda-old.log](https://github.com/nvaccess/nvda/files/8055280/nvda-old.log)

### Expected behavior:
NVDA works fine

### System configuration
#### NVDA installed/portable/running from source:
installed and portable
#### NVDA version:
2021.3.1 and latest alpha

#### Windows version:
Windows 10 21H2 (x64) build 19044.1526

#### Name and version of other software in use when reproducing the issue:
depends 2.2

#### Other information about your system:
None
### Other questions
#### Does the issue still occur after restarting your computer?
Yes
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
No
#### If NVDA add-ons are disabled, is your problem still occurring?
Yes
#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
Yes


Discussion:
Potentially related to https://github.com/nvaccess/nvda/pull/13271
Hi @feerrenrut 
Thank you, I will keep an eye on #13271, Once that pr is merged I will test it.
@cary-rowen  Could you test with the [try build](https://ci.appveyor.com/api/buildjobs/3ohpcq1f4pabvvw4/artifacts/output%2Fnvda_snapshot_pr13271-24570%2Cf4d8375c.exe) for #13271? I hope Appveyor allows you to download it.
Hi @leonardder and @feerrenrut 

Unfortunately I tested the issue with try build of #13271 and it still reproduces.

I've found two cases so far, but they're not related to #13271:
1. NVDA resumes speaking after a long period of silence.
2. Tested the issue on another machine using the same steps. No matter how long it takes, NVDA will not speak unless NVDA is restarted.

Ideally, however, NVDA should not freeze or crash for long periods of time anyway.

Grateful
Cary
@cary-rowen I am testing with NVDA 2023.1 RC1 and I cannot reproduce this issue anymore. Are you still having it with the dependency walker 2.2.6? I tested with x64 and with x86 versions.
@Adriani90 
Hi, I really don't think this issue has been fixed!
I just tested the issue again, and it can still be reproduced stably.
Can you follow the steps in the original description and test again?

* depends22_x64, The specific version number is 2.2.6000.0
* Windows 10 22H2 (AMD64) build 19045.2728
* NVDA alpha-27854

Ok I am on Windows 11, maybe this makes a difference.

Resolving patch:
diff --git a/source/NVDAHelper.py b/source/NVDAHelper.py
--- a/source/NVDAHelper.py
+++ b/source/NVDAHelper.py
@@ -563,7 +563,7 @@ def initialize() -> None:
 		except AttributeError as e:
 			log.error("nvdaHelperLocal function pointer for %s could not be found, possibly old nvdaHelperLocal dll"%name,exc_info=True)
 			raise e
-	localLib.nvdaHelperLocal_initialize()
+	localLib.nvdaHelperLocal_initialize(globalVars.appArgs.secure)
 	generateBeep=localLib.generateBeep
 	generateBeep.argtypes=[c_char_p,c_float,c_int,c_int,c_int]
 	generateBeep.restype=c_int
@@ -588,7 +588,7 @@ def initialize() -> None:
 		log.critical("Error loading nvdaHelperRemote.dll: %s" % WinError())
 		return
 	_remoteLib=CDLL("nvdaHelperRemote",handle=h)
-	if _remoteLib.injection_initialize(globalVars.appArgs.secure) == 0:
+	if _remoteLib.injection_initialize() == 0:
 		raise RuntimeError("Error initializing NVDAHelperRemote")
 	if not _remoteLib.installIA2Support():
 		log.error("Error installing IA2 support")


Test patch: