Don't attempt crash loop detection or automatic restarting on crash when running in secure mode (#19238)
Fixes #19216
Follow-up #19175
### Summary of the issue:
NVDA was failing to start on secure screens, unless the serviceDebug
global parameter was set.
### Description of user facing changes:
NVDA works on secure desktops again.
### Description of developer facing changes:
None
### Description of development approach:
The issue was caused by `utils._crashHandler.CrashStats.crashStatsPath`
assuming that `globalVars.appArgs.logFileName` would always represent a
path. Notwithstanding this, it also wrote to disk, even when
`NVDAState.shouldWriteToDisk` returned `False` (i.e. in scure mode or
running from the launcher).
1. Added several defensive measures to the new `utils._crashHandler`
module.
2. Changed `watchdog.initialize` to no longer add
`utils._crashHandler.crashHandler` as an unhandled exception filter when
running in secure mode.
### Testing strategy:
Ran from source, and executed the following in the python console to
ensure automatic restarts on crash still work as expected:
```py
import ctypes;ctypes.windll.kernel32.DebugBreak()
```
Modified NVDA to allow the scratchpad in secure mode, built a
self-signed launcher, and installed it.
Hit `alt+control+delete`, and observed that NVDA worked as expected.
Added the following global plugin to the scratchpad of the user and
system config:
```py
from globalPluginHandler import GlobalPlugin
import ctypes
from tones import beep
from core import postNvdaStartup
class GlobalPlugin(GlobalPlugin):
def __init__(self):
super().__init__()
postNvdaStartup.register(self.crash)
def crash(self):
beep(500,100)
ctypes.windll.kernel32.DebugBreak()
```
Restarted NVDA, and observed that it started, a tone was heard, and it
crashed, and this only happened 4 times.
Hit `alt+control+delete`, and observed that NVDA started, a tone was
heard, NVDA crashed, and did not restart.
### Known issues with pull request:
When NVDA crashes on the secure desktop, no feedback is given to the
user. However, this is not new.