Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple variable access throws System.NullReferenceException #3877

Closed
3 tasks done
nowakca opened this issue Nov 21, 2023 · 3 comments
Closed
3 tasks done

Simple variable access throws System.NullReferenceException #3877

nowakca opened this issue Nov 21, 2023 · 3 comments

Comments

@nowakca
Copy link

nowakca commented Nov 21, 2023

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

### Environment
PSReadLine: 2.3.4
PowerShell: 7.4.0
OS: Red Hat Enterprise Linux 8.1 (Ootpa)
BufferWidth: 166
BufferHeight: 48

Last 9 Keys:

 1 + 2 Enter
 $ a = 4 Enter


### Exception

System.NullReferenceException: Object reference not set to an instance of an object.
   at InvokeStub_PredictionClient.set_CurrentLocation(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokePropertySetter(Object obj, BindingFlags invokeAttr, Binder binder, Object parameter, CultureInfo culture)

Screenshot

[root@a32ba66750cf /]# pwsh
PowerShell 7.4.0
PS /> 1+2
3
PS /> $a=4
PS />
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
Thank you!

Environment data

Unable to run script as any comments

Steps to reproduce

On my M1 Macbook run the following in Terminal.app

docker run --rm -it --name test --platform linux/amd64 registry.access.redhat.com/ubi8/ubi:8.1 bash

In that container run

curl --silent --show-error https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
yum -y install powershell-7.4.0
pwsh

In that shell run

1+2

Observe expected 3 as output

Then run

$a=4

Get the exception

Any more enters after that just repeat the exception.
Typing in 1+2 repeats the same exception again

Typing help results in a Segmentation fault, and dropping back to Linux's bash

NOTE: If I run pwsh again, it works fine. And when I type in $a, it offers $a=4 as autocomplete even, so it seems to be an issue with starting up from a completely fresh system.

Expected behavior

After typing in $a=4 I expect no exception, and I expect to get a functioning new next prompt.

Actual behavior

The above exception happens, and I'm stuck with that exception.

Relaunching pwsh proceeds as desired, it's just the first run that fails.

Closing the container, starting it up fresh again, and repeating the steps causes the exception again

So it definitely seems to to with some history file or something of that nature not existing.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Nov 21, 2023
@nowakca
Copy link
Author

nowakca commented Nov 27, 2023

Having searched around and dug into other issues (going back into 7.3.0), this looks like it might be a more general "newer versions of .Net don't behave on Docker/Linux that runs via Rosetta", which is very sad if true.

@daxian-dbw
Copy link
Member

@nowakca It does seem to be a .NET issue for 2 reasons:

  1. The exception happened in the .NET reflection code stack.
  2. The reflection call happens on every call to PSConsoleReadLine.ReadLine, namely every time you get the prompt back.
    So, the call worked fine for the first 2 commands 1+2 and $a=4, but failed when the prompt got back after executing $a=4.

Can you please share some pointers about the "newer versions of .Net don't behave on Docker/Linux that runs via Rosetta" issue?

Copy link
Contributor

This issue is closed because it has been marked as requiring author feedback but has not had any activity for 7 days. If you think the issue is still relevant, please reopen and provide your feedback.

@daxian-dbw daxian-dbw removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants