The installer stops with the crashing Vulkan layer named instead of going on with a warning (#1345)

A layer that crashes hostcheck at vkCreateInstance also breaks totk.exe --prepare-shaders in the prepare step and the
game (runtime/vk_device.c create_instance loads the same implicit layers): with the PR's warning the install failed
again after lift and compile. Check.probe_host now turns each listed implicit layer off alone, names the one whose
absence lets the probe pass with its manifest path in check.vulkan_layer_crash, and says how to turn it off
(VK_LOADER_LAYERS_DISABLE=<name> for the user account); when no single layer explains it, check.vulkan_layers_crash
lists the installed ones and offers ~implicit~. The list covers the loader's places: VK_(ADD_)IMPLICIT_LAYER_PATH, the
registry in the 64-bit view or the Linux implicit_layer.d folders, with names read from the manifests. A failed host
check is kept on the context, so key() and run() no longer build and crash it twice, and the App Control reputation
codes 4557-4559 and 4581-4583 count as a block too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Valiantsin DzerakhandClaude Opus 5.5 committed 2026-11-22 15:49:04 +03:00
1 parent 08e44f43ad
commit d181714398
13 files changed
+206 -76

No files matched your search

+100 -40
View File
@@ -41,6 +41,11 @@ import time
import urllib.request
from pathlib import Path
if os.name == 'nt':
import winreg
else:
winreg = None
from . import ini, screens
from . import layout as layouts
from .layout import EXE, SUPPORTED, version_tag
@@ -140,32 +145,63 @@ def exit_code(code):
return str(code)
def implicit_vulkan_layers():
"""Names of the enabled implicit Vulkan layer manifests the Windows registry lists (machine, then user), for the
warning that names the program to update; empty elsewhere or when the registry cannot be read."""
if os.name != 'nt':
return []
import winreg
def layer_manifests():
"""Implicit Vulkan layer manifests where the Khronos loader looks for them (its docs, LoaderLayerInterface.md,
"Layer Discovery"): the folders in VK_IMPLICIT_LAYER_PATH or VK_ADD_IMPLICIT_LAYER_PATH, then on Windows the
manifests HKLM and HKCU\\SOFTWARE\\Khronos\\Vulkan\\ImplicitLayers enable with a DWORD 0, read in the 64-bit view
the 64-bit probe and game use; elsewhere the implicit_layer.d folders. Layers a driver registers under its display
adapter's key are not listed."""
found = []
for root in (winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER):
try:
key = winreg.OpenKey(root, r'SOFTWARE\Khronos\Vulkan\ImplicitLayers')
except OSError:
continue
with key:
i = 0
while True:
try:
path, enabled, _ = winreg.EnumValue(key, i)
except OSError:
break
i += 1
name = Path(path).name
if enabled == 0 and name not in found: # a DWORD 0 enables the manifest, anything else skips it
found.append(name)
for var in ('VK_IMPLICIT_LAYER_PATH', 'VK_ADD_IMPLICIT_LAYER_PATH'):
for part in filter(None, os.environ.get(var, '').split(os.pathsep)):
p = Path(part)
found += sorted(p.glob('*.json')) if p.is_dir() else [p]
if winreg:
for root in (winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER):
try:
key = winreg.OpenKey(root, r'SOFTWARE\Khronos\Vulkan\ImplicitLayers', 0,
winreg.KEY_READ | winreg.KEY_WOW64_64KEY)
except OSError:
continue
with key:
i = 0
while True:
try:
path, enabled, _ = winreg.EnumValue(key, i)
except OSError:
break
i += 1
if enabled == 0: # a DWORD 0 enables the manifest, anything else skips it
found.append(Path(path))
else:
home = Path.home()
config = [os.environ.get('XDG_CONFIG_HOME') or home / '.config',
*(os.environ.get('XDG_CONFIG_DIRS') or '/etc/xdg').split(':'), '/usr/local/etc', '/etc']
data = [os.environ.get('XDG_DATA_HOME') or home / '.local' / 'share',
*(os.environ.get('XDG_DATA_DIRS') or '/usr/local/share:/usr/share').split(':')]
for base in filter(None, config + data):
found += sorted((Path(base) / 'vulkan' / 'implicit_layer.d').glob('*.json'))
return found
def implicit_vulkan_layers():
"""(layer name, manifest path) of each readable implicit Vulkan layer manifest of layer_manifests(), for the
search for the layer that crashes the host check. A manifest the loader cannot read loads no layer and is left
out; a manifest listed twice counts once."""
layers = []
for path in dict.fromkeys(layer_manifests()):
try:
manifest = json.loads(path.read_text(encoding='utf-8-sig'))
except (OSError, ValueError):
continue
entries = (manifest.get('layers') or [manifest.get('layer')]) if isinstance(manifest, dict) else []
for entry in entries:
name = entry.get('name') if isinstance(entry, dict) else None
if isinstance(name, str) and (name, path) not in layers:
layers.append((name, path))
return layers
def linux_glibc():
"""(major, minor) of the C library this Linux process runs on, None elsewhere or when it is not glibc."""
try:
@@ -465,8 +501,19 @@ class Check(Step):
return {}
def host(self, ctx):
"""Builds and runs the host check once per run: key() asks first and run() reports, so a failure is kept on
ctx and raised again rather than a crashing probe and its retries running twice."""
if getattr(ctx, 'host', None) is not None:
return
if getattr(ctx, 'host_error', None) is not None:
raise ctx.host_error
try:
self.check_host(ctx)
except InstallError as e:
ctx.host_error = e
raise
def check_host(self, ctx):
layout, work = ctx.layout, ctx.temp / 'check'
glibc = linux_glibc()
if glibc and glibc < GLIBC_NEEDED and not layout.dev:
@@ -505,17 +552,23 @@ class Check(Step):
ctx.reporter.warning('warn.kernel_old', version='.'.join(map(str, kernel)))
ctx.host = host
# Windows refuses to start a program a policy does not trust: Smart App Control and other App Control policies
# (4551 "An Application Control policy has blocked this file", 4556 and 4580 the same for a bad reputation, issue
# #875), group policy (1260) and an antivirus that flags the file (225, 226). hostcheck is the first program the
# setup builds on this PC; totk.exe is built the same way and unsigned too, so the install cannot go on.
BLOCKED_WINERRORS = {225, 226, 1260, 4551, 4556, 4580}
# Windows refuses to start a program a policy does not trust (issue #875): Smart App Control and other App Control
# policies (4551 "An Application Control policy has blocked this file"; 4556-4559 and 4580-4583 the same with the
# reputation verdict, among them 4559 "Unable to contact reputation service for unknown file"), group policy (1260
# "This program is blocked by group policy") and an antivirus that flags or removes the file (225, 226). hostcheck
# is the first program the setup builds on this PC; totk.exe is built the same way and unsigned too, so the install
# cannot go on.
BLOCKED_WINERRORS = {225, 226, 1260, 4551, 4556, 4557, 4558, 4559, 4580, 4581, 4582, 4583}
LAYER_TRIES = 16 # implicit layers tried one by one in the search for the one that crashes the probe
def probe_host(self, ctx, exe):
"""Runs the host check built by host() and returns its JSON. A probe that crashes inside Vulkan is run again
with the implicit Vulkan layers off (VK_LOADER_LAYERS_DISABLE, Vulkan loader 1.3.234 or later): overlays,
recorders and tuning tools install such layers, and a broken one kills every Vulkan program at
vkCreateInstance (issue #1345, exit code 0xC0000005 after "Checking the processor and the graphics card")."""
"""Runs the host check check_host() built and returns its JSON. A probe that crashes inside Vulkan is run again
with the implicit Vulkan layers off (VK_LOADER_LAYERS_DISABLE=~implicit~, Vulkan loader 1.3.234 or later):
overlays, recorders and tuning tools install such layers, and a broken one kills every Vulkan program at
vkCreateInstance (issue #1345, exit code 0xC0000005 after "Checking the processor and the graphics card").
When that run passes, each listed layer is turned off alone to name the one that crashes. The install stops
either way: totk.exe --prepare-shaders in the prepare step and the game itself load the same layers
(runtime/vk_device.c create_instance), so going on would fail after lift and compile."""
rep = ctx.reporter
r = self.run_probe(exe)
host = parse_host(r.stdout)
@@ -526,17 +579,23 @@ class Check(Step):
rep.log(f'host: the check stopped with exit code {code}; it printed {r.stdout.strip()!r}')
if '"loader": true' not in r.stdout:
raise InstallError('check.host_probe_failed', code=code)
env = dict(os.environ, VK_LOADER_LAYERS_DISABLE='~implicit~')
retry = self.run_probe(exe, env)
host = parse_host(retry.stdout)
if host is None:
retry = self.run_probe(exe, dict(os.environ, VK_LOADER_LAYERS_DISABLE='~implicit~'))
if parse_host(retry.stdout) is None:
rep.log(f'host: without implicit Vulkan layers too: exit code {exit_code(retry.returncode)}, '
f'{retry.stdout.strip()!r}')
raise InstallError('check.vulkan_crash', code=code)
layers = ', '.join(implicit_vulkan_layers()) or '?'
rep.log(f'host: {retry.stdout.strip()} (implicit Vulkan layers off; installed: {layers})')
rep.warning('warn.vulkan_layer_crash', code=code, layers=layers)
return host
layers = implicit_vulkan_layers()
rep.log(f'host: passes with the implicit Vulkan layers off; installed: '
f'{", ".join(f"{n} ({p})" for n, p in layers) or "none listed"}')
culprits = [(name, path) for name, path in layers[:self.LAYER_TRIES]
if parse_host(self.run_probe(exe, dict(os.environ, VK_LOADER_LAYERS_DISABLE=name)).stdout)]
if culprits:
rep.log(f'host: passes without {", ".join(n for n, _ in culprits)}')
raise InstallError('check.vulkan_layer_crash', code=code,
layers=', '.join(f'{n} ({p})' for n, p in culprits),
disable=','.join(n for n, _ in culprits))
raise InstallError('check.vulkan_layers_crash', code=code,
layers=', '.join(f'{n} ({p})' for n, p in layers) or '?')
def run_probe(self, exe, env=None):
try:
@@ -544,7 +603,8 @@ class Check(Step):
except OSError as e:
if getattr(e, 'winerror', None) in self.BLOCKED_WINERRORS:
raise InstallError('check.host_blocked', path=str(exe), detail=e.strerror or str(e)) from None
raise InstallError('check.host_probe_failed', code=f'{getattr(e, "winerror", None) or e.errno}: {e.strerror or e}') from None
raise InstallError('check.host_probe_failed',
code=f'{getattr(e, "winerror", None) or e.errno}: {e.strerror or e}') from None
def inputs(self, ctx):
"""Open both files with the keys as the extraction will. Returns the bytes of both Program NCAs."""