1 Commits
Author SHA1 Message Date
Isaac ConnorandClaude Opus 4.8 74a248f1b1 fix: prevent data race on Monitor ref_image that crashes zmc analysis
On suspend-resume Monitor::CheckAction() called ref_image.DumpImgBuffer()
on the capture thread while the analysis thread was using ref_image in
DetectMotion() -> Image::Delta(). DumpImgBuffer() frees the buffer and nulls
the pointer but leaves width/height/colours intact, so Delta's "different
sized images" guard still passed and the delta helper walked from a null
base pointer, faulting at address 0 on the first row. That is the reported
"Fault address: (nil)" inside the gray8 delta helper. Portrait monitors were
not special; they just made the resume-during-analysis window easy to hit.

Move the reference-image reset onto the thread that owns ref_image:
CheckAction() sets an atomic ref_image_reset_ flag and Analyse() performs
the DumpImgBuffer() itself on its next pass, so the buffer is never freed
out from under an in-flight Delta/Blend. Reject a null buffer in Image::Delta
as a defensive backstop.

Add tests/zm_zone_stride.cpp: a regression test that reproduced the null
delta crash, plus zone coverage at portrait (1080x1920, stride-padded) and
landscape dimensions through the alarmed-pixel and blob paths.

fixes #4983

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQipwf632JGgNH4W7p8cqs
2026-07-19 11:26:03 -04:00