Skip to content

StoreSession: report export thread creation failures - #139

Open
victorstoica114 wants to merge 1 commit into
sigrokproject:masterfrom
victorstoica114:fix-export-thread-creation
Open

victorstoica114 wants to merge 1 commit into
sigrokproject:masterfrom
victorstoica114:fix-export-thread-creation

Conversation

@victorstoica114

Copy link
Copy Markdown

If std::thread construction fails in StoreSession::start(), its exception currently escapes instead of returning false with an error. StoreProgress::run() expects that return value to show the save error. This affects ordinary binary and srzip exports.

Move worker construction into the existing try block and catch std::exception, which covers std::system_error as well as the existing sigrok::Error. Retain the same error reporting, resource ownership, normal worker and setup-saving behavior. No worker becomes joinable after failed construction; a fresh StoreSession can export the same data afterward. Repeated starts on the same exporter and machine-wide OOM recovery are not promised.

The optional Linux diagnostic overrides pthread_create only within its own process and scans no physical drivers. It checks eight fault/control cases: binary/srzip, 2,048 and 2,621,441 samples, one EAGAIN, no escaped exception or false success, exact source bytes, and normal export/replay. Setup saving is disabled in this data-only fixture because it creates no view. Run it after a Unix Makefiles build with tests enabled:

cmake -S . -B build -G "Unix Makefiles" -DENABLE_TESTS=ON
cmake --build build
python3 contrib/check-store-thread.py build export-check

Validation of this exact source on Linux and native Windows/MinGW:

  • Full Release builds and existing CTest pass on both systems.
  • The original implementation reproduces four failures in the eight cases on each OS. Two real StoreProgress calls also let the exception escape; the negative diagnostics catch it at their outer boundary rather than claiming an application crash.
  • Current code passes all eight cases. The two actual error dialogs report the failure, preserve source data and allow an exact fresh export. Native and offscreen Windows configurations pass; Windows diagnostics use the full application's compiled objects and restore their process-local pthread_create import interception on exit.
  • An independent reader verifies 12 normal exports and six dialog-recovery exports byte for byte, including ZIP CRCs, chunk order, channel count, sample rate and size. Partial failed outputs are retained. Ordinary exports gain no atomic-replacement guarantee.

Linux is a VMware guest; Windows is nested KVM. Hardware is excepted for this host file-export exception path: no acquisition, transport or firmware code changes, and no new electrical or user-desktop capture claim.

This three-file change is based directly on upstream af02198. It is independent of #136, #137 and #138 and includes no DLA, collection or Segment changes.

Construct the export worker inside the existing error handler and catch std::exception so std::thread startup failures return false with an error.

Add an optional standalone Linux regression covering one process-local EAGAIN, exact retained source bytes, and normal binary/srzip export and replay at two sizes.
Copilot AI balanced review requested due to automatic review settings November 4, 2026 04:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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