microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.97k stars 1.43k forks source link

`winget` hangs prompting for approval of source agreement terms in PowerShell 7.4.0-preview.6 #3742

Open sba923 opened 11 months ago

sba923 commented 11 months ago

Brief description of your issue

(follow-up to https://github.com/PowerShell/PowerShell/issues/20452)

When winget needs to prompt for approval of the source license terms, it hangs when run under PowerShell 7.4.0-preview.6 running on Windows 11 10.0.22621.2361.amd64fre.ni_release.220506-1250 within Windows Terminal Preview 1.19.2309.25002.

This works fine under PowerShell 7.3.7.

PS> winget list smartm
The `msstore` source requires that you view the following agreements before using.
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US").

Do you agree to all the source agreements terms?
[Y] Yes  [N] No:

Entering 'Y' at this point does nothing: winget cannot read keyboard input.

Steps to reproduce

Run this Update-WinGetSources.ps1 PowerShell script:

#requires -RunAsAdministrator

winget source reset --force
$msix = Join-Path -Path $env:TEMP -ChildPath 'source.msix'
Invoke-WebRequest https://cdn.winget.microsoft.com/cache/source.msix -OutFile $msix
Add-AppXPackage -Path $msix
Remove-Item -Path $msix
winget source update

Then invoke winget list smartm.

At the prompt, type Y

Expected behavior

PS> winget list smartm
The `msstore` source requires that you view the following agreements before using.
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US").

Do you agree to all the source agreements terms?
[Y] Yes  [N] No: Y

Actual behavior

PS> winget list smartm
The `msstore` source requires that you view the following agreements before using.
Terms of Transaction: https://aka.ms/microsoft-store-terms-of-transaction
The source requires the current machine's 2-letter geographic region to be sent to the backend service to function properly (ex. "US").

Do you agree to all the source agreements terms?
[Y] Yes  [N] No:

Keyboard input is ignored. The winget.exe process needs to be killed.

Environment

Windows Package Manager v1.6.2771
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.2361
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.2771.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
sba923 commented 11 months ago

This issue encountered yesterday was 100% reproducible.

It seems that it's no longer the case (system has been restarted in the meantime).

Any clue?

denelon commented 11 months ago

@sba923 I got another report from a different user trying to reproduce this behavior, and we haven't been able to get the device into that state reliably yet.

sba923 commented 11 months ago

If there's anything I can do to help, just tell me.

denelon commented 11 months ago

@sba923 thanks so much for offering. If you have a device in that state or can find some reliable way to get a device in that state, it will make it much easier for us to grab logs and try to isolate the root cause so we can find a fix.

I've just seen several anecdotal instances where a reboot fixes it, so we haven't been able to determine what causes it.

sba923 commented 11 months ago

I don't have a device in that state at this very moment. Next time it happens, what logs / data do you want me to capture?

I have a Process Explorer-capture full dump from one of the last occurrences. FWIW, here's what analyze -v had to say:

0:000> !analyze -v
*******************************************************************************
*                                                                             *
*                        Exception Analysis                                   *
*                                                                             *
*******************************************************************************

KEY_VALUES_STRING: 1

    Key  : Analysis.CPU.mSec
    Value: 484

    Key  : Analysis.Elapsed.mSec
    Value: 38068

    Key  : Analysis.IO.Other.Mb
    Value: 33

    Key  : Analysis.IO.Read.Mb
    Value: 0

    Key  : Analysis.IO.Write.Mb
    Value: 128

    Key  : Analysis.Init.CPU.mSec
    Value: 77

    Key  : Analysis.Init.Elapsed.mSec
    Value: 10348

    Key  : Analysis.Memory.CommitPeak.Mb
    Value: 157

    Key  : Failure.Bucket
    Value: BREAKPOINT_80000003_ucrtbase.dll!translate_text_mode_nolock_char

    Key  : Failure.Hash
    Value: {639c42a6-4c88-886f-bc8f-61d63d42c2a4}

    Key  : Timeline.OS.Boot.DeltaSec
    Value: 8192

    Key  : Timeline.Process.Start.DeltaSec
    Value: 72

    Key  : WER.OS.Branch
    Value: ni_release

    Key  : WER.OS.Version
    Value: 10.0.22621.1

    Key  : WER.Process.Version
    Value: 1.21.2310.4001

FILE_IN_CAB:  winget-hung-202310080945.dmp

NTGLOBALFLAG:  0

PROCESS_BAM_CURRENT_THROTTLED: 0

PROCESS_BAM_PREVIOUS_THROTTLED: 0

APPLICATION_VERIFIER_FLAGS:  0

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 0000000000000000
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 0

FAULTING_THREAD:  00004aac

PROCESS_NAME:  winget.exe

ERROR_CODE: (NTSTATUS) 0x80000003 - {EXCEPTION}  Breakpoint  A breakpoint has been reached.

EXCEPTION_CODE_STR:  80000003

STACK_TEXT:  
00000049`e28fe518 00007ffe`a87765fb     : cc581709`e91f3c69 00007ffe`00000340 00000049`00000002 00000049`e28fe620 : ntdll!NtReadFile+0x14
00000049`e28fe520 00007ffe`a8b07030     : 00000167`0ea97340 00007ffe`a8c00990 00000000`00000004 00000049`e28fe5e8 : KERNELBASE!ReadFile+0x7b
00000049`e28fe590 00007ffe`a8b06dbd     : 00000049`e28fe610 00000167`00000000 00000000`00000000 00000000`00000000 : ucrtbase!translate_text_mode_nolock<char>+0x100
00000049`e28fe5e0 00007ffe`a8b07845     : 00000000`00000000 00000000`00001000 00000000`00000000 00000000`00000001 : ucrtbase!translate_ansi_or_utf8_nolock+0x2d
00000049`e28fe630 00007ffe`a8b0798f     : 00000167`0ea97300 00000167`0ea97340 00000000`00000001 00000000`00000001 : ucrtbase!_read_nolock+0x17d
00000049`e28fe6d0 00007ffe`a8b07bae     : 00000000`00000000 00007ffe`a8bff4a0 00000167`0ea97340 00007ffe`220c5e50 : ucrtbase!_read+0xaf
00000049`e28fe710 00007ffe`a8b07f12     : 00007ffe`a8bff4a0 00000000`ffffffff 00007ffe`a8bff4a0 00000000`00000079 : ucrtbase!common_refill_and_read_nolock<char>+0x76
00000049`e28fe740 00007ffe`22049006     : 00007ffe`a8bff4a0 00007ffe`a8bff4a0 00007ffe`a8bff4a0 00007ffe`220c5db0 : ucrtbase!fgetc+0x122
00000049`e28fe790 00007ffe`2204928b     : 00007ffe`220c5db0 00007ffe`220c5db0 00000000`00000001 00007ffe`220c5e50 : msvcp140!std::basic_filebuf<char,std::char_traits<char> >::uflow+0xb6
00000049`e28fe840 00007ffe`22091250     : 00000000`ffffffff 00000000`0000000a 00000000`00000001 00000049`e28fea10 : msvcp140!std::basic_filebuf<char,std::char_traits<char> >::underflow+0x3b
00000049`e28fe870 00007ffd`b85bcfd1     : 00000000`00000000 00000000`00000001 00000000`00000000 00000049`e28fea10 : msvcp140!std::basic_streambuf<char,std::char_traits<char> >::snextc+0x90
00000049`e28fe8a0 00007ffd`b85bbfb4     : 00007ffe`220c5e50 0e38e38e`38e38e39 00007ffe`220c5e50 00000000`00000090 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x96b1
00000049`e28fe910 00007ffd`b85ed48e     : 00007ffe`220c6000 00000167`0c8e3300 00007ffe`220c6000 00007ffe`220c6000 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x8694
00000049`e28fec10 00007ffd`b85f000e     : 00007ffe`2204bdb5 00000167`0868d100 00000049`e28ffa01 00000049`e28ff2c9 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x39b6e
00000049`e28ff260 00007ffd`b85c9ef0     : 00000167`085b0140 00007ffe`ab40ba46 00000049`e28ffae8 00000049`e28ff600 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x3c6ee
00000049`e28ff330 00007ffd`b85f4733     : 00000167`08630aa8 00000000`00000000 00000167`0867c508 00000167`00000000 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x165d0
00000049`e28ff500 00007ffd`b85c4f52     : 00000167`08630aa8 00000049`e28ff710 00000049`e28ffae8 00000000`00000000 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x40e13
00000049`e28ff6c0 00007ffd`b85c56af     : 00000000`00000000 00000167`0869bb40 00007ffd`b890b730 00000167`08682640 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x11632
00000049`e28ff8b0 00007ffd`b85b8d4d     : 00000167`0869bb40 00000167`0869bb40 00000167`0869bb40 00000167`0869bb58 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x11d8f
00000049`e28ff950 00007ffd`b85530da     : 00000167`0860ca60 00000000`00000000 00000000`00000003 00000000`00000000 : WindowsPackageManager!WindowsPackageManagerConfigurationCompleteOutOfProcessFactoryInitialization+0x542d
00000049`e28ffea0 00007ff6`7c151238     : 00000167`0860ca60 00007ff6`7c1512b9 00000000`00000000 00000000`00000000 : WindowsPackageManager!WindowsPackageManagerCLIMain+0x3a
00000049`e28ffed0 00007ffe`a927257d     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : winget+0x1238
00000049`e28fff10 00007ffe`ab42aa78     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : kernel32!BaseThreadInitThunk+0x1d
00000049`e28fff40 00000000`00000000     : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : ntdll!RtlUserThreadStart+0x28

STACK_COMMAND:  ~0s; .ecxr ; kb

SYMBOL_NAME:  ucrtbase!translate_text_mode_nolock<char>+100

MODULE_NAME: ucrtbase

IMAGE_NAME:  ucrtbase.dll

FAILURE_BUCKET_ID:  BREAKPOINT_80000003_ucrtbase.dll!translate_text_mode_nolock_char_

OS_VERSION:  10.0.22621.1

BUILDLAB_STR:  ni_release

OSPLATFORM_TYPE:  x64

OSNAME:  Windows 10

IMAGE_VERSION:  10.0.22621.608

FAILURE_ID_HASH:  {639c42a6-4c88-886f-bc8f-61d63d42c2a4}

Followup:     MachineOwner
---------
denelon commented 11 months ago

Feedback hub would be a good start: https://aka.ms/winget-feedback

After it's filed, share the URL so it's easier for us to find that specific report.

sba923 commented 6 months ago

Occurred again with PowerShell 7.4.1, created https://aka.ms/AApflkm

Do you want me to share the dump / WinDbg analyze -v output here too?

sba923 commented 4 months ago

Occurred again with PowerShell 7.4.2.

Here are the logs and analyze -v output.

winget.exe_240421_191810.txt

winget-hung-20240421.zip