Skip to content

Startup crash because /proc/stat in inaccessible in Android (accessing boot time required?)  #10290

@christianrondeau

Description

@christianrondeau

Powershell currently crashes because it's trying to get the computer boot time, which can be unavailable (for example on Android). I don't see having access to the computer boot time being a requirement to launch powershell, this could either record the boot time as unavailable or crash when we actually need that value.

Steps to reproduce

  1. Setup a Linux distribution on Android (I used Debian 9 on Android 8 arm 64 using UserLAnd)
  2. Follow the instructions at https://docs.microsoft.com/en-us/powershell/scripting/install/powershell-core-on-arm?view=powershell-6 (I replaced arm32 by
  3. Run pwsh

Expected behavior

Get a powershell prompt

Actual behavior

FailFast:
Access to the path '/proc/stat' is denied. 
    at System.Environment.FailFast(System.String, System.Exception)                                 
    at Internal.Runtime.Augments.EnvironmentAugments.FailFast(System.String, System.Exception)
    at System.Environment.FailFast(System.String, System.Exception)
    at Microsoft.PowerShell.UnmanagedPSEntry.Start(System.String, System.String[], Int32) 
    at Microsoft.PowerShell.ManagedPSEntry.Main(System.String[])

Exception details:
System.UnauthorizedAccessException: Access to the path '/proc/stat' is denied. ---> System.IO.IOException: Permission denied
    --- End of inner exception stack trace ---
    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) 
    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)    at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options) 
    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) 
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) 
    at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks) 
    at System.IO.File.InternalReadAllText(String path, Encoding encoding) 
    at System.IO.File.ReadAllText(String path) 
    at System.Diagnostics.Process.get_BootTime()
    at System.Diagnostics.Process.BootTimeToDateTime(TimeSpan timespanAfterBoot)
    at System.Diagnostics.Process.get_StartTimeCore()
    at System.Diagnostics.Process.get_StartTime()   
    at Microsoft.PowerShell.ConsoleHost.DoCreateRunspace(String initialCommand, Boolean skipProfiles, Boolean staMode, String configurationName, Collection`1 initialCommandArgs) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1618                             
    at Microsoft.PowerShell.ConsoleHost.CreateRunspace(Object runspaceCreationArgs) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1506                           
    at Microsoft.PowerShell.ConsoleHost.DoRunspaceLoop(String initialCommand, Boolean skipProfiles, Collection`1 initialCommandArgs, Boolean staMode, String configurationName) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1421                               
    at Microsoft.PowerShell.ConsoleHost.Run(CommandLineParameterParser cpp, Boolean isPrestartWarned) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1383         

    at Microsoft.PowerShell.ConsoleHost.Start(String bannerText, String helpText, String[] args) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs:line 1
    at Microsoft.PowerShell.ConsoleShell.Start(String bannerText, String helpText, String[] args) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleShell.cs:line 299
    at Microsoft.PowerShell.UnmanagedPSEntry.Start(String consoleFilePath, String[] args, Int32 argc) in /PowerShell/src/Microsoft.PowerShell.ConsoleHost/host/msh/ManagedEntrance.cs:line 72    
Aborted

Environment data

N/A

Metadata

Metadata

Assignees

Labels

Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions