Skip to content

FIX - Shm truncation guard#549

Open
Sahil-u07 wants to merge 4 commits into
ControlCore-Project:mainfrom
Sahil-u07:shm-truncation-guard
Open

FIX - Shm truncation guard#549
Sahil-u07 wants to merge 4 commits into
ControlCore-Project:mainfrom
Sahil-u07:shm-truncation-guard

Conversation

@Sahil-u07
Copy link
Copy Markdown
Contributor

Summary

Fix a correctness bug in the C++ shared-memory write path that previously logged a warning and continued writing truncated payloads. Oversized payloads now fail fast by throwing a std::runtime_error, preventing silently corrupted data from flowing through a running study.

Changes

  • concore.hpp
    • Added an explanatory comment above SHM_SIZE.
    • Replaced warning-and-truncate behavior with a std::runtime_error when the payload size is >= SHM_SIZE in both shared-memory write paths.
  • test_shm_abort.py
    • New focused regression tests that compile a minimal C++ driver and verify oversized payloads fail while in-range payloads succeed.

Why this matters

Silent truncation of SHM payloads can corrupt downstream neuromodulation calculations and produce incorrect scientific results without any visible error in running studies. This change forces a visible failure so users notice and fix configuration (increase SHM_SIZE or reduce payloads) rather than producing silent, incorrect outputs.

Testing / CI

  • Ensure CI runs the new tests on a Linux runner with g++ installed.
  • Expected results on Linux:
    • test_oversized_payload_throws — non-zero exit, stderr contains "Aborting", no "truncated".
    • test_within_limit_succeeds — exit 0, no stderr.
    • test_exactly_at_limit_throws — non-zero exit.
    • test_one_under_limit_succeeds — exit 0, no stderr.

Copilot AI review requested due to automatic review settings May 15, 2026 18:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants