java-topology/defects/gearsystem/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

24 lines
1.1 KiB
Text

DEFECT FOUND: see gearsystem-0001
MOAD-0001 (CWE-407): DEFECT -- gearsystem-0001
- Processor::CheckBreakpoints() called per Z80 opcode: O(B) linear scan.
- Processor::CheckMemoryBreakpoints() called per memory Read/Write AND
per VDP memory access (Video.cpp:532,575,582,608,648): O(B) each.
- Z80 at ~3.58 MHz + VDP VRAM/CRAM accesses: >5M O(B) scans/second.
- At B=64: >320M comparisons/second in debug mode.
- Fix: std::unordered_set<u16> index per type for O(1) lookup.
MOAD-0002 (Intertangle): CLEAN
- GearsystemCore aggregates subsystems by design (intentional emulator
architecture). Each subsystem (Processor, Memory, Video, Audio,
Cartridge) has independent state and a clean interface.
MOAD-0003 (Leaked Context): CLEAN
- No thread_local or TLS usage. Single-threaded emulation loop.
MOAD-0004 (CWE-312): CLEAN
- Pure game emulator with no authentication, credentials, or secrets.
TraceLogger logs CPU opcodes and register state -- no sensitive data.
MOAD-0005 (Thundering Herd): CLEAN
- Single-threaded, deterministic emulation. No concurrent cache patterns.