Skip to content
TheChatArchiveThe Chat Archive
composer-2.5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Fatal crash in (*Program).SingleThreaded on snapshot update [code] Interface No new…

  1. User

    Fatal crash in (*Program).SingleThreaded on snapshot update

    internal/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:669
    

    Interface

    No new interfaces are introduced.

  2. Assistant

    Investigating the crash in (*Program).SingleThreaded by reading the stack trace locations and related snapshot-update code.

  3. Assistant

    Let me write a test to reproduce the crash, then implement the fix.

  4. Assistant

    Identifying the crash: SingleThreaded() dereferences p.Options().SingleThreaded when Config is nil, which happens if CreateProgram runs before a configured project's CommandLine is loaded. Implementing guards at the project and compiler layers.

  5. Assistant

    The crash is a nil pointer dereference in (*Program).SingleThreaded() when CreateProgram runs before a configured project has a loaded CommandLine.

    Root cause

    SingleThreaded() resolves the effective value like this:

    func (p *Program) SingleThreaded() bool {
    	if options := p.Options(); options != nil {
    		return p.opts.SingleThreaded.DefaultIfUnknown(options.SingleThreaded).IsTrue()
    	}
    	return p.opts.SingleThreaded.IsTrue()
    }
    

    Previously it called p.Options().SingleThreaded unconditionally. Options() returns nil when ProgramOptions.Config is nil, so NewProgram panicked during snapshot updates for configured projects that were created as placeholders (e.g. solution-style ancestor tsconfig.json projects) before their config was acquired.

    Fix

    Three defensive guards, no new interfaces:

    1. SingleThreaded() — handle nil Options() safely.
    2. CreateProgram() — return early if getCommandLineWithTypingsFiles() is nil, instead of calling NewProgram with a nil config.
    3. updateProgram() — skip CreateProgram when the project or its CommandLine is nil, so placeholders are not built until config is loaded.

    A regression test (TestSnapshotUpdateDoesNotCrashForSolutionAncestorPlaceholder) covers the solution-tsconfig + closed-file snapshot update path from the stack trace.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.