java-topology/defects/gearboy/scan
russell@unturf.com 64c65b567d gearboy+gearsystem: 2 CWE-407 defects (breakpoint O(B) scan per memory access); minivmac all 5 MOADs CLEAN
gearboy-0001: Processor::CheckBreakpoints() and CheckMemoryBreakpoints() scan
m_breakpoints std::vector O(B) on every opcode dispatch and every memory
Read/Write. At ~4 MHz with B=64 breakpoints: ~256M comparisons/second.
Fix: std::unordered_set<u16> index for O(1) point-breakpoint lookup.
8.4x speedup measured in Java model.

gearsystem-0001: Same defect in GearSystem (SMS/GG emulator). Compounded by
Video.cpp calling CheckMemoryBreakpoints() on every VDP VRAM/CRAM access
(5 additional call sites beyond CPU). >5M O(B) scans/second at 3.58 MHz.
7.1x speedup measured in Java model.

minivmac: All 5 MOADs CLEAN. LocalFindATTel() bounded to 16-20 ATT entries
by design (constant, not O(N^2)). Single-threaded, no credentials, no TLS.
2026-03-31 19:55:45 -04:00

25 lines
1.2 KiB
Text

DEFECT FOUND: see gearboy-0001
MOAD-0001 (CWE-407): DEFECT -- gearboy-0001
- Processor::CheckBreakpoints() called per opcode: O(B) linear scan over
m_breakpoints vector. B = number of active breakpoints.
- Processor::CheckMemoryBreakpoints() called per memory Read/Write via
Memory_inline.h: O(B) linear scan per access.
- At ~4 MHz with B=64 breakpoints: ~256M comparisons/second in debug mode.
- Fix: std::unordered_set<u16> index for O(1) point-breakpoint lookup.
MOAD-0002 (Intertangle): CLEAN
- GearboyCore aggregates subsystems (Processor, Memory, Cartridge, Video,
Audio) but this is intentional emulator architecture, not god-object
coupling. Each subsystem has a clean interface and independent state.
MOAD-0003 (Leaked Context): CLEAN
- No thread_local or TLS usage. Gearboy is single-threaded per emulation
instance. Audio uses SDL callbacks but carries no request context.
MOAD-0004 (CWE-312): CLEAN
- No authentication, credentials, or secrets. Pure game emulator.
TraceLogger logs CPU registers and memory -- no sensitive data.
MOAD-0005 (Thundering Herd): CLEAN
- Single-threaded emulation. No concurrent lazy-init cache patterns.