ISSUE DESCRIPTION Fatal crash in (*Program).SingleThreaded on snapshot update [code]…
- User
ISSUE DESCRIPTION
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.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
Assistant
Confirmed. Now let's check the second location (~1037) similarly.
Assistant
Now let's implement the fix. First, add a helper method on
Projectto invalidate the cache correctly:Assistant
Now update the call sites: the two
p.commandLineWithTypingsFiles = nillines, and the ATA update site.Assistant
All three sites updated. Let's verify the surrounding context looks correct.
Assistant
Now let's check that
syncpackage is already imported in project.go (it is, used forsync.Oncefield). Let's build.Assistant
Build succeeds. Now let's run the existing project tests to confirm nothing's broken and the previous test still passes.
Assistant
All three mutation sites (plus the initial construction in
NewProject/NewInferredProject, which doesn't need it since it's a fresh struct) are now covered withinvalidateCommandLineWithTypingsFiles(). Now let's write a focused white-box reproduction test to directly validate the fix at theProjectmethod level, without needing the full compiler host — I can stub minimal pieces.Assistant
Good, that gives a real
vfs.FS. Now let's write the temp white-box test.Assistant
Now let's confirm this test would have failed without the fix, by reverting the fix temporarily and re-running.
Assistant
This confirms the bug in the old code (nil returned → matches the crash root cause). Now let's restore the fix and clean up.
Assistant
Good, temp test file removed. Now let's rebuild and run the full test suite for the project package (and compiler package, since that's where the crash function lives) to make sure everything still passes.
Assistant
Let's also run the broader test suite around lsp/session related areas and do a race-detector run for the project package to catch any concurrency issues introduced.
Assistant
All pass, including with the race detector. Let's view the final diff.
Assistant
This is a clean, minimal fix. Let's run the full test suite once more broadly to be safe (lsp package too, since it's involved in the crash trace).
Assistant
All good. Now 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.