Public repository: timo / schach

Reader

Ein aufgeräumtes Schach-Programm für GNOME

test(zustand): random test reports hangs and hard crashes

public

test(zustand): random test reports hangs and hard crashes

A watchdog dumps all thread stacks when no step happened for 120 s, and
faulthandler is enabled so a segfault in GTK or GStreamer leaves a stack.
Progress is printed every 50 steps. Two earlier parallel runs ended
without a report; this makes the next such case diagnosable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changeset10b46625c4419ea4f662870dd29f50e9c59e212a
Author (claimed)Timo Stolz <timo.stolz@nullachtvierzehn.de>,
Parents12e981706f99
Children7ebf6fe8583f
Pushlog
by timo via ssh
by timo via ssh

modified tools/zustand_zufall.py +8 −0

@@ -21,6 +21,7 @@ ohne Zufall und ohne Engines nachspielt
2121
 
2222
 import argparse
2323
 import datetime
24
+import faulthandler
2425
 import os
2526
 import random
2627
 import sys
@@ -47,6 +48,7 @@ from gi.repository import Gdk, Gio, GLib
4748
 from schach import app as schach_app, opening, recording, savegames, training, zustand  # noqa: E402
4849
 
4950
 STEP_MS = 400  # Zeit zwischen zwei Schritten: Engines und Ton laufen dazwischen weiter
51
+WATCHDOG_S = 120  # so lange ohne Schritt: Stapel aller Threads ausgeben (hängt die Hauptschleife?)
5052
 
5153
 # Rätsel für training.sqlite: (FEN vor dem Gegnerzug, Gegnerzug, Lösung in UCI)
5254
 PUZZLES = [
@@ -204,7 +206,12 @@ class Fuzzer:
204206
         return steps
205207
 
206208
     def step(self):
209
+        faulthandler.cancel_dump_traceback_later()
210
+        faulthandler.dump_traceback_later(WATCHDOG_S, exit=False)
211
+        if len(self.trail) % 50 == 0:
212
+            print(f"… Schritt {len(self.trail)}: " + " → ".join(n for _w, n in self.trail[-8:]), flush=True)
207213
         if self.left <= 0:
214
+            faulthandler.cancel_dump_traceback_later()
208215
             self.app.quit()
209216
             return False
210217
         self.left -= 1
@@ -230,6 +237,7 @@ class Fuzzer:
230237
 
231238
 
232239
 def main():
240
+    faulthandler.enable()  # auch ein harter Absturz (Segfault in GTK/GStreamer) hinterlässt Stapel
233241
     parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
234242
     parser.add_argument("--schritte", type=int, default=300)
235243
     parser.add_argument("--seed", type=int, default=None)