Repository navigation
CED reader: detect and diagnose sonpipe/sonpy crashes on .smrx reads - #114
Merged
Merged
Conversation
| tmp = [tempname() '.bin']; | ||
| cleaner = onCleanup(@() deletefile(tmp)); | ||
| errfile = [tempname() '.err']; | ||
| cleaner = onCleanup(@() deletefile(tmp)); %#ok<NASGU> |
| cleaner = onCleanup(@() deletefile(tmp)); | ||
| errfile = [tempname() '.err']; | ||
| cleaner = onCleanup(@() deletefile(tmp)); %#ok<NASGU> | ||
| cleanerErr = onCleanup(@() deletefile(errfile)); %#ok<NASGU> |
| 'Could not read sonpipe output file: %s', tmp); | ||
| end | ||
| closer = onCleanup(@() fclose(fid)); | ||
| closer = onCleanup(@() fclose(fid)); %#ok<NASGU> |
| exe = ndr.format.ced.sonpipe.executable(); | ||
| cmd = [exe ' ' args]; | ||
| errfile = [tempname() '.err']; | ||
| cleanerErr = onCleanup(@() deletefile(errfile)); %#ok<NASGU> |
Contributor
CED's sonpy (used to read 64-bit .smrx files via the sonpipe bridge) can
fail an internal C++ assertion and abort() (SIGABRT) on certain
files/channels. That kills the reader process mid-stream; previously the
MATLAB layer could return silently truncated or empty data with no error,
because it trusted the process exit status alone -- unreliable when the
Apple Silicon 'arch -x86_64' wrapper masks a signal death as exit 0.
invoke_binary now captures stderr separately and requires the CLI's
completion sentinel ("sonpipe: wrote N ..."); a missing sentinel or a
count that does not match the captured bytes raises sonpipe:crash /
sonpipe:truncated naming the exact command, instead of returning short
data. invoke_text captures stderr to its own file so a warning or crash
text can no longer corrupt the JSON passed to jsondecode, and surfaces it
on failure. The doc notes point users at SONPIPE_LOG for breadcrumb
logging that pinpoints the crashing sonpy call.
The self-contained fake_sonpipe.py test double now emits the same
completion sentinel as the real CLI so the unit tests exercise the new
contract.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C1UYvbvczg9QvqKg8YNr4k
Add a Troubleshooting section to the ndr.setup.sonpipe help text pointing users at the SONPIPE_LOG breadcrumb log for diagnosing a sonpy crash while reading a CED file, and noting that the reader now surfaces a mid-read abort as a sonpipe:crash/sonpipe:truncated error. This is the natural discovery point for NDR/MATLAB users, who invoke sonpipe indirectly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C1UYvbvczg9QvqKg8YNr4k
stevevanhooser
force-pushed
the
claude/ndr-matlab-sonpipe-crashes-o6hnvx
branch
from
July 21, 2026 21:08
66e8a79 to
9642092
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reading certain 64-bit CED Spike2 files through the sonpipe bridge crashed CED's
sonpyreader (SIGABRT) with no error surfaced in MATLAB — the readerreturned silently truncated/empty data. This PR makes the CED reader detect such
a crash and turn it into a clear error, and documents how to diagnose it. The
actual crash fix lives in the companion sonpipe PR (VH-Lab/sonpipe#5); this side
is the MATLAB-facing detection and docs.
What changed
+ced/+sonpipe/private/invoke_binary.m— captures stderr separately andrequires the CLI's completion sentinel (
sonpipe: wrote N …), checking thatNmatches the bytes captured. A missing sentinel or a count mismatch raisessonpipe:crash/sonpipe:truncatednaming the exact command, instead ofreturning short data. This holds even when an intermediate
arch -x86_64wrapper (Apple Silicon) masks the child's non-zero exit status.
+ced/+sonpipe/private/invoke_text.m— captures stderr to its own file soa warning or crash text can no longer corrupt the JSON passed to
jsondecode,and surfaces it on failure.
+ndr/+setup/sonpipe.m— adds a Troubleshooting section documenting theSONPIPE_LOGbreadcrumb log (setenv('SONPIPE_LOG','1')) for pinpointing acrashing
sonpycall, the natural discovery point for MATLAB users.tools/tests/.../fake_sonpipe.py— the self-contained test double nowemits the same completion sentinel as the real CLI, so the unit tests exercise
the new contract.
Why
sonpyaborts inside its compiled binary, which a MATLABtry/catchcannotintercept. The reader previously trusted the child process's exit status alone;
across the Apple-Silicon wrapper a signal death could look like success, so bad
data flowed back with no error. Validating the CLI's own completion sentinel
makes a mid-read crash impossible to miss.
Notes
sonpycall after the sample read) and provides the
SONPIPE_LOGdiagnostics. Userspick up the fix by updating their sonpipe install; this branch is MATLAB-only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01C1UYvbvczg9QvqKg8YNr4k
Generated by Claude Code