Skip to content

The latest daily throws Cannot create boxed ByRef-like values when accessing $OutputEncoding #7301

Closed

Description

@TylerLeonhardt

Steps to reproduce

$OutputEncoding

Expected behavior

Preamble          :
BodyName          : utf-8
EncodingName      : Unicode (UTF-8)
HeaderName        : utf-8
WebName           : utf-8
WindowsCodePage   : 1200
IsBrowserDisplay  : True
IsBrowserSave     : True
IsMailNewsDisplay : True
IsMailNewsSave    : True
IsSingleByte      : False
EncoderFallback   : System.Text.EncoderReplacementFallback
DecoderFallback   : System.Text.DecoderReplacementFallback
IsReadOnly        : True
CodePage          : 65001

Actual behavior

format-default : Cannot create boxed ByRef-like values.
+ CategoryInfo          : NotSpecified: (:) [format-default], InvalidProgramException
+ FullyQualifiedErrorId : System.InvalidProgramException,Microsoft.PowerShell.Commands.FormatDefaultCommand

Environment data

Latest Daily

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-preview.10545
PSEdition                      Core
GitCommitId                    6.1.0-preview.10545
OS                             Darwin 17.6.0 Darwin Kernel Version 17.6.0: Tue May  8 15:22:16 PDT 2018; root:xnu-4570.61.1~1/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

Activity

  1. bergmeister commented on Jul 17, 2018

    @bergmeister
    Contributor

    This also happens on Windows (6.1.0-preview.744 and 6.1.0-preview.746 so it must have been introduced at least 2 days ago) and it seems the error formatting is slightly off as well:

    > $OutputEncoding
    format-default : Cannot create boxed ByRef-like values.
    + CategoryInfo          : NotSpecified: (:) [format-default], InvalidProgramException
    + FullyQualifiedErrorId : System.InvalidProgramException,Microsoft.PowerShell.Commands.FormatDefaultCommand
    
    > $PSVersionTable
    
    Name                           Value
    ----                           -----
    PSVersion                      6.1.0-preview.744
    PSEdition                      Core
    GitCommitId                    v6.1.0-preview.744
    OS                             Microsoft Windows 10.0.17134
    Platform                       Win32NT
    PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
    PSRemotingProtocolVersion      2.3
    SerializationVersion           1.1.0.1
    WSManStackVersion              3.0
  2. daxian-dbw commented on Jul 18, 2018

    @daxian-dbw
    Member

    This issue was surfaced by the changes to Mshexpression.cs in the PR #6898 -- getting property values via binder instead of DotNetAdapter.

    The root cause is the new property Preamble added to Encoding type in 2.1.0 -- the property type is System.ReadOnlySpan[byte], a ByRef-Like type. The ByRef-Like value type was newly introduced in 2.1.0, and obviously our binder doesn't handle it properly (this value type is supposed to be used only on the stack, and thus cannot be boxed). You can trigger the same failure even with 6.1.0-preview.3, by running $OutputEncoding.Preamble.

    It's a more fundamental issue that we have to fix in our compiler/binder code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Resolution-Fixed

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions