Fatal crash in (*Program).SingleThreaded on snapshot update [code] Interface No new…
- User
Fatal crash in
(*Program).SingleThreadedon snapshot updateinternal/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
I’ll trace the snapshot-update path into
Program.SingleThreaded, identify the invalid state causing the crash, then patch it and run focused tests plus the relevant package suite. - Assistant
The failure occurs before file processing:
SingleThreadedreads compiler options through the project’s parsed command line. I’m checking ownership and locking around that command-line state, because snapshot cloning can rebuild projects concurrently and a stale or partially updated configuration is the most likely fault boundary. - Assistant
I found a concrete cache invariant violation: the augmented command-line cache uses
sync.Once, but update paths clear only the cached pointer. If that project clone has already computed the cache, theOnceremains completed; the next program creation receives a nil config and crashes exactly inSingleThreaded. I’m centralizing cache invalidation so both pieces of state reset together, including ATA changes that alter the augmented roots. - Assistant
The patch now resets both the cached command line and its completion guard, so recomputation cannot silently return nil. I also applied the same invalidation when installed typings change; otherwise a program can retain outdated ATA root files even without crashing. The focused project tests are still running.
- Assistant
The normal project and compiler suites pass. I’m running the project suite under the race detector as a final check because the bug involves copy-on-write snapshot state and a resettable synchronization guard.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.