Skip to content

Guard late physics input and record plugin lifecycle hooks - #643

Merged
freezy merged 3 commits into
masterfrom
fix/late-physics-input
Nov 24, 2026
Merged

freezy merged 3 commits into
masterfrom
fix/late-physics-input

Conversation

@freezy

@freezy freezy commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Late input during table teardown can reach the plunger after the native physics queue has been disposed. Check the queue under the same lock used for disposal before creating a direct physics state.

Persist the plugin ID and hook in the crash diagnostics snapshot before startup and teardown calls. A failed diagnostic write cannot interrupt cleanup.

Evidence

  • The Edit Mode regression threw NullReferenceException after queue disposal. With the change, the regression and all seven cabinet physics tests passed.
  • An IOException from a diagnostic sink originally aborted plugin cleanup. The regression now verifies stop and disposal complete. The plugin suite passed 113 tests with one skip.

Merge Danger

The changes are reversible and affect direct physics mutations after native queue disposal and plugin lifecycle diagnostics.

@freezy freezy changed the title Reject late physics input after table teardown Guard late physics input and record plugin lifecycle hooks Nov 24, 2026
@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the remaining concern is non-blocking crash diagnostics.

Findings

  1. P2 Crashes can lose hook markers ▶

Summary

Guards direct physics input after queue disposal and adds plugin hook markers to the diagnostic context.

  • Late physics input skips mutations after the event queue is disposed.
  • Plugin lifecycle steps appear in diagnostics without interrupting cleanup.

Reviews (2) · Last reviewed commit: "plugins: persist hook markers without ri..." · Reviewed by Greptile

SetStatus(entry.Factory.Descriptor.Id, PluginState.Starting, phase.ToString(), phase);
using var deadline = CancellationTokenSource.CreateLinkedTokenSource(cancellation);
deadline.CancelAfter(StartupTimeout);
entry.Log.Info($"Entering plugin hook {phase}.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Crashes can lose hook markers

With NLogPluginLog, these markers enter LogQueueTarget, whose writer waits up to 50 ms before draining. A native hook that crashes immediately can take down the process before its marker reaches the file. AutoFlush only helps after the writer receives the line.

Provide a way to write these markers durably before entering native-facing hooks.

@freezy
freezy merged commit 15a4a6b into master Nov 24, 2026
20 of 21 checks passed
@freezy
freezy deleted the fix/late-physics-input branch November 24, 2026 14:03
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.

1 participant