mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-10-05 18:48:18 +00:00
The app died with SIGSEGV before drawing anything, on every entry point including --help. The window minimum size was pre-seeded into Kivy's Config, and WindowBase.__init__ is the only place Kivy reads it - so it was applied from inside WindowSDL.create_window(), while Window.initialized was still False. If the window SDL has just made is smaller than that minimum, SDL resizes it on the spot; the resize comes back through the SDL event filter into EventLoop.idle(), which runs the clock and re-enters create_window(). Still not initialised, that call runs setup_window() again and resizes again, until the C stack gives out. A scaled HiDPI session is enough to reach it: with sdl2-compat on SDL3 under Wayland sizes come back in logical points, so the inherited 800x600 default arrives as a 500x375 window, under the 760x520 minimum. Set the minimum on Window once it exists instead, where the same resize takes Kivy's cheap already-initialised path. That exposed a second fault on the same path. _install_kivy_logging attached a bare StreamHandler() to Kivy's own logger, and kivy.logger replaces sys.stderr with a stream that feeds whatever is written to it back in as a warning - kivy/logger.py cautions about exactly this. Any warning _KivyNoise did not drop answered itself until the recursion limit stopped it, with stderr as the broken part, so nothing legible came out. Not theoretical: this machine logs "MTD: Unable to open device" at startup, which would have killed the app as soon as the segfault was out of the way. Point the handler at the real stderr, which Kivy leaves alone. Behaviour change: a window that opens smaller than 760x520 is now grown to it, rather than the constraint being imposed while the window is built. Testing: 257 passed, 2 skipped (was 254/2); --help, a plain launch, --dump on a generated sample and -v all start and stay up; black clean. Python-only change, so no client or firmware build matrix applies. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
70 lines
2.3 KiB
Python
70 lines
2.3 KiB
Python
"""Startup checks. These run in a subprocess: importing the app builds the
|
|
Kivy window, so a segfault would take the test session down with it."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
LAUNCHER = ROOT / "ePassport.py"
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")),
|
|
reason="starting the app needs a display",
|
|
)
|
|
def test_the_launcher_starts() -> None:
|
|
"""--help must not die on a signal."""
|
|
proc = subprocess.run(
|
|
[sys.executable, str(LAUNCHER), "--help"],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=180,
|
|
env={**os.environ, "KIVY_NO_CONSOLELOG": "1"},
|
|
)
|
|
how = (
|
|
f"killed by signal {-proc.returncode}"
|
|
if proc.returncode < 0
|
|
else f"exited {proc.returncode}"
|
|
)
|
|
assert proc.returncode == 0, f"--help {how}\n{proc.stderr[-2000:]}"
|
|
assert "--dump" in proc.stdout
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
not (os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY")),
|
|
reason="importing the app builds a window, which needs a display",
|
|
)
|
|
def test_a_kivy_warning_does_not_take_the_app_down_with_it() -> None:
|
|
"""A Kivy warning must not loop through the stderr Kivy replaced."""
|
|
proc = subprocess.run(
|
|
[
|
|
sys.executable,
|
|
"-c",
|
|
"import sys; sys.path.insert(0, %r)\n" % str(ROOT)
|
|
+ "from epassport.app import _install_kivy_logging\n"
|
|
+ "from kivy.logger import Logger\n"
|
|
+ "_install_kivy_logging(False)\n"
|
|
+ "Logger.warning('an ordinary kivy warning')\n",
|
|
],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=180,
|
|
)
|
|
assert proc.returncode == 0, f"exited {proc.returncode}\n{proc.stderr[-2000:]}"
|
|
assert "RecursionError" not in proc.stderr
|
|
|
|
|
|
def test_the_window_minimum_is_not_pre_seeded_into_kivy_config() -> None:
|
|
"""Read the source: importing the app to check is what crashed."""
|
|
source = (ROOT / "epassport" / "app.py").read_text()
|
|
assert not re.search(
|
|
r"""Config\.set\(\s*['"]graphics['"]\s*,\s*['"]minimum_""", source
|
|
), "the minimum size must be set on Window, not pre-seeded into Config"
|