core: harden instance attachment and typed-nil boundaries - #1
Draft
Joshua Tenner (jtenner) wants to merge 6 commits into
Draft
core: harden instance attachment and typed-nil boundaries#1Joshua Tenner (jtenner) wants to merge 6 commits into
Joshua Tenner (jtenner) wants to merge 6 commits into
Conversation
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
This hardens instance lifecycle ownership and several fail-closed boundaries discovered during a repository-wide correctness, coverage, and concurrency audit.
Detachcannot miss anAttachthat is still constructing its namespace.State.NamespaceHandlewhenever the resource table has retired that handle, even when the backend'sClosereports an error.HostModulevalues before callingMemoryor resolving instance identity.Root causes
Manager.Attachpreviously published state only after backend construction, whileDetachtreated an absent published state as already detached. A concurrent detach could therefore return successfully and then allow the attach to publish an orphaned state. The same construction window also allowed a duplicate backend factory invocation and left no panic-safe release path.resource.Table.CloseHandleretires a handle before invoking the resource'sClose; conditioningState.NamespaceHandlecleanup on a nil close error left a stale advertised handle after retirement.Plain interface
nilchecks do not detect typed-nil pointers. Calling methods through those interfaces could panic instead of failing closed.The dynamic IPv4 path duplicated only part of the static identity validation and therefore admitted loopback and limited broadcast addresses.
Validation
On the full repository audit checkout at base commit
76392ea102b847a633a3cdd3e77ec54ef524dda2:go vet ./...passedinternal/instance/corepassed 50 repeated race-instrumented runs with the lifecycle regressionsThe execution workspace was recycled after those runs. I reconstructed this minimal six-file branch from the same base commit, verified the three baseline blobs byte-for-byte against GitHub, verified every submitted remote blob against the local content hash, and reran the exact reconstructed changes in an isolated semantic harness, including 20 race-instrumented repetitions for each affected package.
Scope
The branch intentionally excludes unrelated static-analysis cleanup found during the audit so this PR remains focused on correctness fixes and their regression tests.