Vscode-powershell: Visual Studio Code PowerShell Extension crashes when IntelliSense about to pop out on passing param to custom function

Created on 3 Sep 2018  路  10Comments  路  Source: PowerShell/vscode-powershell

System Details

- Operating system name and version: macOS High Sierra 10.13.6
- VS Code version: 1.26.1
- PowerShell extension version: v1.8.4
- Output from `$PSVersionTable`:
Name                           Value
----                           -----
PSVersion                      6.0.4
PSEdition                      Core
GitCommitId                    v6.0.4
OS                             Darwin 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul  6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS /Users/vichamp> code -v
1.26.1
493869ee8e8a846b0855873886fc79d480d342de
x64
PS /Users/vichamp> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      8      4      0


PS /Users/vichamp> code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
PS /Users/vichamp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.4
PSEdition                      Core
GitCommitId                    v6.0.4
OS                             Darwin 17.7.0 Darwin Kernel Version 17.7.0: Fri Jul  6 19:54:51 PDT 2018; root:xnu-4570.71.3~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

function mytest {

}

mytest # extension crashes

PowerShell extension for Visual Studio Code crashes when InteliSense about to parse mytest custom function.

Attached Logs

logs.zip

Issue-Bug

Most helpful comment

Update to PowerShell Extension 1.9.0 and this issue disappears.

All 10 comments

Thanks for opening an issue @victorwoo. This looks like a crash in the URI class in the CodeLens reference provider.

The workaround is to disable CodeLens: https://github.com/PowerShell/vscode-powershell/issues/1174#issuecomment-379232062

I suspect the non-ASCII characters are causing the crash (it's occurring when the AbsoluteUri property is referenced here). Hopefully we can fix it -- the crash seems to be occurring deep within the Uri class.

Yes, the https://github.com/PowerShell/vscode-powershell/issues/1174#issuecomment-379232062 workaround works. Thanks!

Further information:
There are really some Chinese characters in the file path. I did some tests, and hope them helps:

PS /Users/vichamp/鑴氭湰/Reduce-Directory> (Get-Item ./test.ps1).FullName
/Users/vichamp/鑴氭湰/Reduce-Directory/test.ps1
PS /Users/vichamp/鑴氭湰/Reduce-Directory> (New-Object System.Uri ((Get-Item ./test.ps1).FullName)).AbsoluteUri
file://file:/Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory/test.ps1
PS /Users/vichamp/鑴氭湰/Reduce-Directory> (New-Object System.Uri ("file://" + (Get-Item ./test.ps1).FullName)).AbsoluteUri
# EMPTY OUTPUT HERE!
PS /Users/vichamp/鑴氭湰/Reduce-Directory>

I can't reproduce this on Ubuntu 18.04 LTS. It may be macOS specific.

I just tried this on my Mac (OS 10.13.6, PS 6.1.0):

PS| rob@Desktop> [uri]::new('file:///Users/vichamp/鑴氭湰/Reduce-Directory/test.ps1').AbsoluteUri
file:///Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory/test.ps1/Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory/test.ps1

@victorwoo it looks like this might have been an issue in .NET Core 2.0 which was what we used in PowerShell Core 6.0.4.

Can you upgrade to PowerShell Core 6.1 and try again?

PS Core 6.1:

> [Uri]::new("/Users/vichamp/鑴氭湰/Reduce-Directory").AbsoluteUri
file:///Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory/Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory

PS Core 6.0.4:

>   [Uri]::new("/Users/vichamp/鑴氭湰/Reduce-Directory").AbsoluteUri                                                             
file://file:/Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory

Note the extra file:.

On macOS 10.13.6 (17G2307)

PS Core 6.0.4:

PS /Users/vichamp> [Uri]::new("/Users/vichamp/鑴氭湰/Reduce-Directory").AbsoluteUri                   file://file:/Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory
PS /Users/vichamp> [uri]::new('file:///Users/vichamp/鑴氭湰/Reduce-Directory/test.ps1').AbsoluteUri   
# EMPTY

PS Core 6.1.0:

PS /Users/vichamp> [Uri]::new("/Users/vichamp/鑴氭湰/Reduce-Directory").AbsoluteUri    
file:///Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory/Users/vichamp/%E8%84%9A%E6%9C%AC/Reduce-Directory

I think the result on PS Core 6.1 still error.

Yes, try $uri.LocalPath

On macOS 10.13.6 (17G2307) with PS Core 6.1.0:

PS /Users/vichamp> [Uri]::new("/Users/vichamp/鑴氭湰/Reduce-Directory").LocalPath
/Users/vichamp/鑴氭湰/Reduce-Directory

It seems OK.

Update to PowerShell Extension 1.9.0 and this issue disappears.

Was this page helpful?
0 / 5 - 0 ratings