Skip to content

Fix session file loading crash, deploy the native DLL, and add a README - #16

Merged
Skorinn merged 4 commits into
masterfrom
integration
Sep 3, 2026
Merged

Skorinn merged 4 commits into
masterfrom
integration

Conversation

@Skorinn

@Skorinn Skorinn commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Four changes found by running the application rather than only its tests.

Opening a session file crashed the application

STATUS_STACK_OVERFLOW, confirmed in the Windows event log, faulting in ntdll.dll. The application died about two seconds after a file was opened.

Loading a session sets the simulate toggle to match the file it came from. The handler for that toggle worked out its new state by inverting what was recorded rather than by reading the toggle, then wrote the result back to the toggle from inside its own event:

Checked = true    (the file says simulated, the toggle is clear)
  -> Simulated = !true = false -> Checked = false -> fires again
  -> Simulated = !false = true -> Checked = true  -> fires again -> without end

This is reached by opening any session recorded in a different mode to the one currently selected, which includes the ordinary case of opening a simulated session in a freshly started application. The file itself has nothing to do with it: a properly closed file and one left unfinished both brought the application down in the same way.

The handler now takes its state from the toggle and no longer writes to it, so setting it from code settles. A test covers the invariant, reaching the toggle by reflection as it is not exposed.

This blocked the recovery of unfinished session files entirely. That work went through five rounds of review on the previous pull request and could not be reached through the interface at all.

The native DLL was never deployed next to the application

Starting a session threw DllNotFoundException for TruRNGpro.dll. The build placed it in the solution bin directory and in the test output, but nothing put it beside the application in its own output directory, which is where the application runs from and so where it looks for it. The test project had been copying it into its own output all along, which is why the tests exercised the device interface while the application could not load it.

README

Describes what the application records and analyses, how to build and run it, the session file format and the recovery behaviour, the layout of the three projects, and how to run the tests. It also notes that the licensing of the third-party header in TruRNGpro has not been established, which is worth settling before the code is distributed.

CommonControls.dll

Updated to the build supplied for this work. There is no source for it here, so it is carried as a binary the same way DeviceInterfaces.dll is.

Verification

Driven through the interface with the controls operated directly, rather than against the classes behind them:

Execute tab 38 of 38
Analyze tab and recovery 13 of 13
Unit tests 207 of 207

Covering recording (average 0.499973, standard deviation 3.94e-3), pause and resume halting and continuing at the exact point counts, loading and appending 81 to 113 points, the baseline against result comparison, and recovery end to end: the application killed while recording, reopened, 50 points recovered, the recovery reported to the user, the session continued to 82 points and the file left valid.

🤖 Generated with Claude Code

https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w

Skorinn and others added 4 commits September 2, 2026 07:06
Describes what the application records and analyses, how to build and run it,
the session file format and the recovery behaviour, the layout of the three
projects, and how to run the tests. Points at the coding guidelines already in
the repository.

Notes that the licensing of the third-party header in TruRNGpro has not been
established, which is worth settling before the code is distributed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Starting a session threw DllNotFoundException for TruRNGpro.dll. The native
DLL was copied to the solution bin directory and into the test output, but
nothing put it next to the application in its own output directory, which is
where the application runs from and so where it looks for it.

The test project already copies the DLL into its output, which is why the
tests exercised the device interface without trouble while the application
could not load it at all.

The application project now does the same. Verified by loading the built
assembly with neither the PATH nor the working directory pointing at the DLL,
calling InitializeDevice in simulate mode and reading from the simulator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Opening a session file took the application down with a stack overflow.

Loading a session sets the simulate toggle to match the file it came from.
The handler for that toggle worked out the new state by inverting what was
recorded rather than by reading the toggle, and then set the toggle from that
result. Setting it from code with a value the recording disagreed with left
the two of them setting each other without end.

The handler now takes the state from the toggle and no longer writes to it,
so setting it from code settles.

This is reached by opening any session recorded in a different mode to the one
currently selected, which includes the ordinary case of opening a simulated
session in a freshly started application. The file itself has nothing to do
with it; a properly closed file and one left unfinished both brought the
application down in the same way.

Found by driving the interface rather than the classes behind it. The unit
tests do not build the form's event wiring, and a session had to be started
before opening a file for the toggle to already agree and the fault to be
missed. A test covers the invariant now, reaching the toggle by reflection as
it is not exposed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Replaces the committed binary with the build supplied for this work. There is
no source for it in this repository, so it is carried as a binary the same way
DeviceInterfaces.dll is.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153VVkWg7DQmdaNLcvtY37w
Copilot AI lite review requested due to automatic review settings September 3, 2026 15:11

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.

🟢 Approval recommended

The changes directly address the reported crash and deployment issue with low-risk, well-scoped edits and include a regression test for the crash scenario.

Pull request overview

Fixes a WinForms crash when loading session files by preventing recursive toggling of the Simulate checkbox, ensures the native TruRNGpro.dll is deployed alongside the application output so the app can actually P/Invoke it at runtime, and documents build/run/test and session-file details in a new README.

Changes:

  • Prevent infinite recursion/stack overflow by updating the simulate-toggle handler to read from the control state (and not write back into it).
  • Add a component test that exercises setting the simulate toggle from code (regression coverage for the crash path).
  • Copy TruRNGpro.dll into the application output directory during the app project’s post-build step, and add a repository README with build/run/test guidance and file format notes.
File summaries
File Description
README.md Adds documentation for purpose, build/run steps, tests, and session XML format/recovery behavior.
RandomNumberGenerator.Test/GeneratorForm.Test.cs Adds a regression test covering programmatic simulate-toggle setting without re-entrant toggling.
RandomNumberGenerator.csproj Updates post-build to deploy TruRNGpro.dll into the app output folder.
GeneratorForm.cs Fixes simulate-toggle event handling to avoid recursive CheckedChanged behavior.
Review details
  • Files reviewed: 4/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Skorinn
Skorinn merged commit 1e4a112 into master Sep 3, 2026
1 check passed
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