Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 20, 2026

Race condition causes modelLineProjections array to become out of sync with projectedModelLineLineCounts during model updates. When external callers (e.g., mainThreadEditor.ts) invoke getVisibleRanges() during this window, accessing modelLineProjections[modelLineNumber - 1] throws undefined error.

Changes:

  • Add getModelLineProjection(modelLineNumber) helper that returns undefined when index is out of bounds
  • Add null checks in public methods returning safe defaults:
    • getViewLineContent''
    • getViewLineLength0
    • getViewLineMinColumn / getViewLineMaxColumn1
    • getViewLineData → fallback ViewLineData with empty content
  • Add same guards to private helpers: getMinColumnOfViewLine, getMaxColumnOfViewLine, getModelStartPositionOfViewLine, getModelEndPositionOfViewLine
private getModelLineProjection(modelLineNumber: number): IModelLineProjection | undefined {
    return this.modelLineProjections[modelLineNumber - 1];
}

public getViewLineMinColumn(viewLineNumber: number): number {
    const info = this.getViewLineInfo(viewLineNumber);
    const lineProjection = this.getModelLineProjection(info.modelLineNumber);
    if (!lineProjection) {
        return 1;
    }
    return lineProjection.getViewLineMinColumn(this.model, info.modelLineNumber, info.modelLineWrappedLineIdx);
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • disallowed.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=12427 --enable-crash-reporter=0a6244d1-1868-4ba9-ba04-846583393c75,no_channel --user-data-dir=/tmp/vscode-tests-1768953438515 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2993599158436563845,1044423022455121245,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 /home/REDACTED/.co-auth .2 ldd x86-64.so.2 bash (dns block)
    • Triggering command: .build/electron/code-oss .build/electron/code-oss --no-sandbox test/unit/electron/index.js --crash-reporter-directory=/home/REDACTED/work/vscode/vscode/.build/crashes s/li�� nibrowser-wpe/install-dependencies.sh -v che/ms-playwright/chromium_headless_shell-1194/chrome-linux/headless_shell exit --run src/vXvfb .2 cal/bin/ldd che/ms-playwrigh0 nibr�� ound-networking ound-timer-throttcp tnet/tools/ldd orward-cache ad -side-phishing-dbash ent-extensions-w-c (dns block)
  • example.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=12427 --enable-crash-reporter=0a6244d1-1868-4ba9-ba04-846583393c75,no_channel --user-data-dir=/tmp/vscode-tests-1768953438515 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2993599158436563845,1044423022455121245,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 /home/REDACTED/.co-auth .2 ldd x86-64.so.2 bash (dns block)
    • Triggering command: .build/electron/code-oss .build/electron/code-oss --no-sandbox test/unit/electron/index.js --crash-reporter-directory=/home/REDACTED/work/vscode/vscode/.build/crashes s/li�� nibrowser-wpe/install-dependencies.sh -v che/ms-playwright/chromium_headless_shell-1194/chrome-linux/headless_shell exit --run src/vXvfb .2 cal/bin/ldd che/ms-playwrigh0 nibr�� ound-networking ound-timer-throttcp tnet/tools/ldd orward-cache ad -side-phishing-dbash ent-extensions-w-c (dns block)
  • mobile.events.data.microsoft.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=12427 --enable-crash-reporter=0a6244d1-1868-4ba9-ba04-846583393c75,no_channel --user-data-dir=/tmp/vscode-tests-1768953438515 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,2993599158436563845,1044423022455121245,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 /home/REDACTED/.co-auth .2 ldd x86-64.so.2 bash (dns block)
    • Triggering command: .build/electron/code-oss .build/electron/code-oss --no-sandbox test/unit/electron/index.js --crash-reporter-directory=/home/REDACTED/work/vscode/vscode/.build/crashes s/li�� nibrowser-wpe/install-dependencies.sh -v che/ms-playwright/chromium_headless_shell-1194/chrome-linux/headless_shell exit --run src/vXvfb .2 cal/bin/ldd che/ms-playwrigh0 nibr�� ound-networking ound-timer-throttcp tnet/tools/ldd orward-cache ad -side-phishing-dbash ent-extensions-w-c (dns block)
  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=10345 --enable-crash-reporter=0a6244d1-1868-4ba9-ba04-846583393c75,no_channel --user-data-dir=/tmp/vscode-tests-1768952977634 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4743992538289350805,14766294595139264140,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 x86-64.so.2 est/unit/browsersh ldd modules/@npmcli/node build/lib/electron.ts x86-64.so.2 (dns block)
    • Triggering command: .build/electron/code-oss .build/electron/code-oss --no-sandbox test/unit/electron/index.js --crash-reporter-directory=/home/REDACTED/work/vscode/vscode/.build/crashes --run src/vs/editor/test/browser/viewModel/modelLineProjection.test.ts x86-64.so.2 cal/bin/ldd bin/ldd ldd run-script/lib/n--noprofile ldd nibr�� x86-64.so.2 (dns block)
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=10490 --enable-crash-reporter=0a6244d1-1868-4ba9-ba04-846583393c75,no_channel --user-data-dir=/tmp/vscode-tests-1768952988791 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,4583171642203889526,10176158874905604066,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 n/ldd l to the X server" "/tmp/server-99.xkm" x86-64.so.2 x86-64.so.2 .2 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Unhandled Error] Cannot read properties of undefined (reading 'getViewLineMinColumn')</issue_title>
<issue_description>Issue created from VS Code Errors Analysis Dashboard

Error Bucket

f804359c-29cc-43d8-2b79-87fbb328af5d

Error Message

Cannot read properties of undefined (reading 'getViewLineMinColumn')

Stack Trace

    at iss.getViewLineMinColumn (./src/vs/editor/common/viewModel/viewModelLines.ts:739:61)
    at lss.getLineMinColumn (./src/vs/editor/common/viewModel/viewModelImpl.ts:795:21)
    at lss.getCompletelyVisibleViewRange (./src/vs/editor/common/viewModel/viewModelImpl.ts:680:29)
    at lss.getVisibleRanges (./src/vs/editor/common/viewModel/viewModelImpl.ts:621:32)
    at hu.getVisibleRanges (./src/vs/editor/browser/widget/codeEditor/codeEditorWidget.ts:549:35)
    at N2.f (./src/vs/workbench/api/browser/mainThreadEditor.ts:92:21)
    at N2.readFromEditor (./src/vs/workbench/api/browser/mainThreadEditor.ts:36:55)
    at SIs.p (./src/vs/workbench/api/browser/mainThreadEditor.ts:214:34)
    at s (./src/vs/workbench/api/browser/mainThreadEditor.ts:291:10)
    at updateProperties (./src/vs/workbench/api/browser/mainThreadEditor.ts:310:4)
Raw Stack Trace (minified)
TypeError: Cannot read properties of undefined (reading 'getViewLineMinColumn')     at iss.getViewLineMinColumn (out/vs/workbench/workbench.desktop.main.js:290:47541)     at lss.getLineMinColumn (out/vs/workbench/workbench.desktop.main.js:290:68538)     at lss.getCompletelyVisibleViewRange (out/vs/workbench/workbench.desktop.main.js:290:66709)     at lss.getVisibleRanges (out/vs/workbench/workbench.desktop.main.js:290:66008)     at hu.getVisibleRanges (out/vs/workbench/workbench.desktop.main.js:293:751)     at N2.f (out/vs/workbench/workbench.desktop.main.js:542:10789)     at N2.readFromEditor (out/vs/workbench/workbench.desktop.main.js:542:10214)     at SIs.p (out/vs/workbench/workbench.desktop.main.js:542:11890)     at s (out/vs/workbench/workbench.desktop.main.js:542:12647)     at Nce.value (out/vs/workbench/workbench.desktop.main.js:542:12779)

Details

Property Value
Version 1.108.1
Commit 585eba7c
Last Seen 2026-01-19T23:59:45.546Z
Total Hits 25.3M
Affected Users 705.0K
Platforms Linux, Mac, Windows
Product VSCode

This issue was automatically created from the VS Code Errors Dashboard

<agent_instructions>Before jumping into fixing, do search in vscode's github repo trying to find existing issues which may be duplicates of this. Then check the issue has already been fixed, propose fixes if it is new one.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 20, 2026 23:50
Fix for issues #213371 and #287067 where getViewLineMinColumn and similar
methods could crash with "Cannot read properties of undefined" when
modelLineProjections array is out of sync with projectedModelLineLineCounts
due to race conditions during model updates.

Added null checks in getViewLineContent, getViewLineLength, getViewLineMinColumn,
getViewLineMaxColumn, and getViewLineData methods to return safe defaults
when the line projection is undefined.

Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
Address code review feedback:
- Add null checks in getMinColumnOfViewLine, getMaxColumnOfViewLine,
  getModelStartPositionOfViewLine, and getModelEndPositionOfViewLine
- Improve getViewLineData fallback to handle edge case where model
  has no lines by using Math.max/min to get safe line number

Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
Remove unnecessary Math.max/min calculation since we just need line 1 tokens
for the empty fallback ViewLineData.

Co-authored-by: bryanchen-d <41454397+bryanchen-d@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unhandled error reading properties of undefined Fix undefined access in viewModelLines.ts getViewLineMinColumn Jan 21, 2026
Copilot AI requested a review from bryanchen-d January 21, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Unhandled Error] Cannot read properties of undefined (reading 'getViewLineMinColumn')

2 participants