PowerShell / PowerShellGetv2

PowerShellGet is the Package Manager for PowerShell
https://www.PowerShellGallery.com
MIT License
432 stars 138 forks source link

Find-Module gettting Unhandled Exception #23

Closed SteveL-MSFT closed 8 years ago

SteveL-MSFT commented 8 years ago

From @ishu3101 on September 2, 2016 1:22

When I run the command Find-Module Markdown on Ubuntu Linux 14.04, I'm getting this error message.

Unhandled Exception: System.UnauthorizedAccessException: Access to the path '/sys/class/net/lo/operstate' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.UnixFileStream.CheckFileCall(Int64 result, Boolean ignoreNotSupported)
   at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
   at System.Net.NetworkInformation.LinuxNetworkInterface.GetOperationalStatus(String name)
   at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)
   at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary`2 interfaces, String name)
   at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)
   at Interop.Sys.EnumerateInterfaceAddresses(IPv4AddressDiscoveredCallback ipv4Found, IPv6AddressDiscoveredCallback ipv6Found, LinkLayerAddressDiscoveredCallback linkLayerFound)
   at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces()
   at System.Net.NetworkInformation.NetworkInterfacePal.GetIsNetworkAvailable()
   at CallSite.Target(Closure , CallSite , Type )
Aborted

Copied from original issue: PowerShell/PowerShell#2165

SteveL-MSFT commented 8 years ago

From @vors on September 2, 2016 14:17

cc @raghushantha @quoctruong

tenortim commented 8 years ago

This also prevents running the vmware/powercli Docker code as supplied because the CEIP code hits this same backtrace:

root [ /powershell ]# /usr/bin/powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

Unhandled Exception: System.UnauthorizedAccessException: Access to the path '/sys/class/net/lo/operstate' is denied. ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at System.IO.UnixFileStream.CheckFileCall(Int64 result, Boolean ignoreNotSupported)
   at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.File.InternalReadAllText(String path, Encoding encoding)
   at System.Net.NetworkInformation.LinuxNetworkInterface.GetOperationalStatus(String name)
   at System.Net.NetworkInformation.LinuxNetworkInterface..ctor(String name)
   at System.Net.NetworkInformation.LinuxNetworkInterface.GetOrCreate(Dictionary`2 interfaces, String name)
   at System.Net.NetworkInformation.LinuxNetworkInterface.<>c__DisplayClass5_0.<GetLinuxNetworkInterfaces>b__2(String name, LinkLayerAddressInfo* llAddr)
   at Interop.Sys.EnumerateInterfaceAddresses(IPv4AddressDiscoveredCallback ipv4Found, IPv6AddressDiscoveredCallback ipv6Found, LinkLayerAddressDiscoveredCallback linkLayerFound)
   at System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces()
   at System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
   at VMware.VimAutomation.Ceip.CeipManager.ComputeInstanceId()
   at VMware.VimAutomation.Ceip.CeipManager.GetEnvironmentData()
   at VMware.VimAutomation.Ceip.CeipManager.DoCeipWorkflow(Object state)
Aborted (core dumped)
bmanikm commented 8 years ago

@tenortim Could you please let us know why your back trace is related to this issue in Find-Module cmdlet? Do you know whether CEIP is using Find-Module cmdlet? from the back trace System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(), your reported issue is not related to the Find-Module cmdlet or PowerShellGet module.

tenortim commented 8 years ago

Hi @bmanikm, in both cases, the exception/crash is identical: Access to the path '/sys/class/net/lo/operstate' is denied. ---> System.IO.IOException: Permission denied and it's being called from the same routine: System.IO.UnixFileStream.CheckFileCall

In both cases, the stacks are identical all the way back to System.Net.NetworkInformation.LinuxNetworkInterface.GetLinuxNetworkInterfaces()

The bug isn't in Find-Module, it's in the code path that both of these stack traces follow. It just so happens that Find-Module is triggering this. If I had to guess, it's trying to open /sys/class/net/lo/operstate read/write which won't work because it's a readonly sysfs file.

bmanikm commented 8 years ago

This is happening due to https://github.com/dotnet/corefx/issues/12969.