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 program construction path, reproduce the crash with the focused test suite, then patch and verify it.
- Assistant
The crash occurs before file processing, when
SingleThreadeddereferences program options. I’m checking how project-createdProgramOptionscan temporarily lack configuration during snapshot cloning and whether the intended fallback already exists elsewhere. - Assistant
The construction inputs are normally non-nil, so a defensive nil check would only hide the symptom. The suspicious path is concurrent snapshot cloning of the same immutable
Program; I’m stress-running the project tests under the race detector to isolate the shared state involved. - Assistant
I found the concrete failure: within one snapshot build, a project can be updated, have its command line changed, and then be updated again. The cached “command line plus typings” pointer is cleared, but its
sync.Onceremains spent; the next lookup returnsnil, which reachesNewProgramand crashes inSingleThreaded. I’m patching cache invalidation to reset both pieces and adding a regression around the two-update sequence. - Assistant
The patch now resets the memoization guard whenever either the base command line or installed typings changes. That also fixes a related stale-cache case where ATA changes could retain the previous augmented root set. Formatting and static diff checks are clean; the race-enabled project suite is still running.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.