Files
Sylpheed/tools/re-capture/waitobj_report.py
Sylpheed RE agent 0b7fd59489 re: the frozen wait-object capture, and screen_id was never a freeze test
Caught the freeze by waiting for the event (frozen.py + in_flight) instead of
sleeping a guessed interval; freeze_waitobj.sh splits into boot/watch so the
wait is not capped by one Bash call. Verified hard: a frame minutes later is
byte-identical to the capture.

Healthy vs frozen, same run: 20 -> 24 wait frames, XEvent 19 -> 23,
XSemaphore 8 -> 7. The signature is per-thread -- 17 of 24 threads sit on the
exact object they were on, four previously-running threads park, and T74/T75
move off a semaphore onto an event. So the freeze is not a whole-emulator stall.

Also corrects the previous entry's test: screen_id reads 'flight' during a
freeze by design, which is why frozen.py exists. Re-testing the saved frames
says that run was genuinely healthy, but it was right by luck.

heavy_read.py added to test whether the instrument provokes the freeze: I/O is
free (371 MB in 0.1s, page cache), the cost is Python-level CPU. One data point
-- 670s clean, then frozen 54s after the inducer started -- recorded as n=1, not
as causation.
2026-08-25 09:02:48 +00:00

104 lines
3.9 KiB
Python
Executable File

#!/usr/bin/env python3
"""Turn the gdb wait-object dumps into a table, discarding what does not check out.
The two waiting functions do not put the same thing in %rbx (see
freeze_waitobj.sh), so they are parsed separately:
Wait rbx = this -> [rbx] is the vtable
WaitMultiple rbx = XObject** -> [[rbx+8i]] is object i's vtable
%ebp holds the count only at the prologue: WaitMultiple reuses it at 8fc158
(`mov 0x10(%rax),%ebp`), and it reads 0 at the point these captures interrupt.
So the array length is NOT taken from a register -- entries are read until one
stops resolving, which is the same self-validating rule used for everything
else here.
Every reading is validated the same way: gdb's `info symbol` must resolve it to
a `vtable for ...` symbol. A polymorphic object's first word always is one, so
anything else is a misread and is COUNTED but not interpreted. That check is
what the reading is worth -- without it a stale register looks like a result.
"""
import re, sys, collections
VT = re.compile(r'vtable for ([\w:]+) \+ (\d+)')
HDR = re.compile(r'=== (\w+) T(\d+) (Wait|WaitMultiple) f(\d+) ===')
def parse(tag):
"""-> list of (thread, kind, count, [vtable-or-None per slot])"""
try:
txt = open('/tmp/fz-obj-%s.txt' % tag, errors='replace').read()
except FileNotFoundError:
return []
out, cur = [], None
for line in txt.splitlines():
line = line.replace('(gdb) ', '')
h = HDR.search(line)
if h:
if cur: out.append(cur)
cur = dict(th=h.group(2), kind=h.group(3), count=None, slots=[], bad=0)
continue
if not cur: continue
m = re.search(r'rbp\s+0x[0-9a-f]+\s+(\d+)', line)
if m: cur['count'] = int(m.group(1)) & 0xffffffff
if 'info symbol' in line or line.startswith('$'): continue
v = VT.search(line)
if v:
cur['slots'].append(v.group(1))
elif 'No symbol matches' in line:
cur['slots'].append(None); cur['bad'] += 1
if cur: out.append(cur)
return out
def report(tag):
recs = parse(tag)
print('=== %s: %d wait frames ===' % (tag, len(recs)))
if not recs: return collections.Counter()
tally = collections.Counter()
for r in recs:
# take entries up to the first one that did not resolve
live = []
for s_ in r['slots']:
if s_ is None: break
live.append(s_)
for s in live:
tally[s if s else '<unresolved>'] += 1
print(' T%-4s %-13s n=%d %s' % (
r['th'], r['kind'], len(live),
', '.join(live) or '(nothing readable)'))
print(' --- objects waited on:')
for k, c in tally.most_common():
print(' %-45s %d' % (k, c))
return tally
def per_thread(tag):
d = {}
for r in parse(tag):
live = []
for s_ in r['slots']:
if s_ is None: break
live.append(s_.replace('xe::kernel::', ''))
d[int(r['th'])] = '%s(%s)' % (r['kind'], ','.join(live))
return d
def diff_threads(a, b):
"""The tally alone hides the signature -- WHICH thread moved is the result."""
x, y = per_thread(a), per_thread(b)
print('=== per-thread %s -> %s ===' % (a, b))
print(' %-6s %-32s %-32s' % ('thread', a, b))
for t in sorted(set(x) | set(y), reverse=True):
fa, fb = x.get(t, '--'), y.get(t, '--')
print(' T%-5d %-32s %-32s %s' % (t, fa, fb, '' if fa == fb else ' <-- CHANGED'))
if __name__ == '__main__':
tallies = {t: report(t) for t in (sys.argv[1:] or ['healthy'])}
if len(tallies) > 1:
a, b = list(tallies)
print('=== %s -> %s ===' % (a, b))
keys = set(tallies[a]) | set(tallies[b])
for k in sorted(keys):
x, y = tallies[a][k], tallies[b][k]
print(' %-45s %3d -> %-3d %s' % (k, x, y, '' if x == y else ' CHANGED'))
diff_threads(a, b)