ISSUE DESCRIPTION Fatal crash in (*Program).SingleThreaded on snapshot update [code]…
- User
ISSUE DESCRIPTION
Fatal crash in
(*Program).SingleThreadedon snapshot updatecodeinternal/compiler.(*Program).SingleThreaded() internal/compiler/program.go:416 internal/compiler.NewProgram() internal/compiler/program.go:274 internal/project.(*Project).CreateProgram() internal/project/project.go:376 internal/project.(*ProjectCollectionBuilder).updateProgram.func2.1() internal/project/projectcollectionbuilder.go:1055 internal/project/dirty.(*Box[...]).Change() internal/project/dirty/box.go:41 internal/project.(*ProjectCollectionBuilder).updateProgram.func2() internal/project/projectcollectionbuilder.go:1052 internal/project/dirty.(*Box[...]).Locked() internal/project/dirty/box.go:57 internal/project.(*ProjectCollectionBuilder).updateProgram() internal/project/projectcollectionbuilder.go:1051 internal/project.(*ProjectCollectionBuilder).DidRequestFile() internal/project/projectcollectionbuilder.go:397 internal/project.(*Snapshot).Clone() internal/project/snapshot.go:353 internal/project.(*Session).updateSnapshot() internal/project/session.go:1101 internal/project.(*Session).getSnapshot() internal/project/session.go:819 internal/project.(*Session).getSnapshotAndDefaultProject() internal/project/session.go:877 internal/project.(*Session).GetLanguageService() internal/project/session.go:890 internal/lsp.init.func1.registerLanguageServiceDocumentRequestHandler[...].13() internal/lsp/server.go:826 internal/lsp.(*Server).handleRequestOrNotification() internal/lsp/server.go:669Interface
No new interfaces are introduced.
Assistant
Let's revert the debug panic first, then write a real repro test to confirm this exact scenario triggers the crash before applying the fix.
Assistant
Now let's also check the ATA update path that doesn't reset it at all (staleness bug):
Assistant
Now let's add the helper method in project.go, right before
getCommandLineWithTypingsFiles:Assistant
Now let's update the three call sites in projectcollectionbuilder.go:
Assistant
Now let's update the test file to use the fixed path and verify it passes, then also apply the defensive
Program.Options()fix as a second layer of protection.Assistant
Now let's remove this temporary test file (per instructions not to add tests), and instead try to build a more realistic end-to-end reproduction through the actual Session/LSP flow to make sure the real crash path is fixed too.
Assistant
Now let's build and run gofmt to fix alignment, then run the broader test suite.
Assistant
Now let's build the whole repo and run the broader test suite (project, compiler, tsoptions) to make sure nothing is broken.
Assistant
All pass. Now let's try to build a full end-to-end reproduction through the real Session/LSP path to validate the actual reported crash scenario is fixed. Let's construct it using the white-box
package projecttest approach with two documents processed in a single generation.Assistant
InferredProject()getter exists. Let's write the test.Assistant
Now let's first check this test reproduces the crash against the ORIGINAL (buggy) code, by temporarily reverting our fix, then re-apply.
Assistant
There's already a
noopClientdefined in that file within the same package. Let's reuse it.Assistant
Now let's restore my fix and verify the compiler-level crash mechanism precisely matches the reported stack trace, then clean up.
Assistant
Good, my three fixes are restored and the temp test file is removed. Let's verify the exact panic mechanism reported in the issue, using a direct compiler-level test to confirm
Program.Options()fix prevents it (and would have crashed before), by temporarily reverting just the compiler fix:Assistant
Now confirm it would crash without the fix:
Assistant
This is the EXACT reported crash line (
program.go:416), confirmed reproduced and fixed. Let's clean up the temp test file and do a final full verification run.Assistant
Let's review the final diff and run the full relevant test suites once more.
Assistant
This looks good. Now let's run the full build + broader test suites once more to be safe.
Assistant
All tests pass. Let's view the final diff once more in full to confirm everything is clean and there are no leftover debug artifacts.
Assistant
Clean. Let's go through the checklist:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.