microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
111.49k stars 6.56k forks source link

[KBM] Adding a shortcut to remap crashes PowerToys #8693

Closed evoL closed 3 years ago

evoL commented 3 years ago

When I try to add a shortcut to remap using the KeyboardManager, PowerToys crashes.

How to reproduce

  1. Open PowerToys (doesn't matter if you run as administrator)
  2. Go to the Keyboard Manager
  3. Click on Remap shortcut
  4. Click the + button
  5. It crashes.

Additional information

I also found the following in the Event Viewer:

Faulting application name: PowerToys.exe, version: 0.28.0.0, time stamp: 0x5fc922a4
Faulting module name: KERNELBASE.dll, version: 10.0.19041.662, time stamp: 0xec58f015
Exception code: 0xc000027b
Fault offset: 0x000000000010bd5c
Faulting process ID: 0x2230
Faulting application start time: 0x01d6d7af329b469b
Faulting application path: C:\Program Files\PowerToys\PowerToys.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report ID: f4ad0a5a-2a6b-4fc1-96a7-0115f9af034b
Faulting package full name: 
Faulting package-relative application ID: 
enricogior commented 3 years ago

@evoL can you please update .NET Core https://download.visualstudio.microsoft.com/download/pr/513acf37-8da2-497d-bdaa-84d6e33c1fee/eb7b010350df712c752f4ec4b615f89d/windowsdesktop-runtime-3.1.10-win-x64.exe

and then try it on 0.29.3? Thanks.

chrismarts commented 3 years ago

Fixed for me with 0.29.3 and latest .NET Core!

evoL commented 3 years ago

Unfortunately this doesn't fix the issue for me. After just an update to 0.29.3 it still crashes.

I downloaded the .NET Core runtime from the provided link, but the installer only gave me the options to Repair or Uninstall, so I think I might have already had the latest version. Anyway, after repairing and rebooting, PowerToys still crashes when adding a shortcut to remap.

enricogior commented 3 years ago

@evoL open a command prompt and run "%PROGRAMFILES%\PowerToys\Tools\BugReportTool.exe" (double quotes are important) that will create a zip file on you desktop named like this PowerToysReport_2021-01-04-12-02-08.zip You can drag and drop it in a GitHub comment. Thanks.

evoL commented 3 years ago

@enricogior Thanks, here's the report. PowerToysReport_2021-01-04-12-05-32.zip

I allowed myself to peek at the output and this seems very relevant:

ERROR: 11:50:48.1731357
    [Method]: LoadProfile [Class]: KeyboardManagerViewModel
    Exception encountered when loading Keyboard Manager profile
Object reference not set to an instance of an object.
Inner exception: 

Stack trace: 
   at Microsoft.PowerToys.Settings.UI.Views.KeyboardManagerPage.CombineRemappings(List`1 remapKeysList, UInt32 leftKey, UInt32 rightKey, UInt32 combinedKey)
   at Microsoft.PowerToys.Settings.UI.Views.KeyboardManagerPage.FilterRemapKeysList(List`1 remapKeysList)
   at Microsoft.PowerToys.Settings.UI.Library.ViewModels.KeyboardManagerViewModel.LoadProfile()
enricogior commented 3 years ago

@evoL thanks a lot!

enricogior commented 3 years ago

@evoL can you confirm that you didn't have any keyboard/shortcut mapping defined?

evoL commented 3 years ago

Yes. I noticed that on a clean install on PowerToys with no settings modified. Screenshots from PowerToys settings show empty lists:

In case it's useful, I do have Caps Lock remapped to Control through the Registry, as described in https://superuser.com/a/949533.

enricogior commented 3 years ago

@evoL

I do have Caps Lock remapped to Control through the Registry

Thanks for the info, but that shouldn't have any effect on the Settings app.

enricogior commented 3 years ago

Note: the setting.json for the KBM looks OK and using it on my machine didn't cause any problem.

{"properties":{"activeConfiguration":{"value":"default"},"keyboardConfigurations":{"value":["default"]}},"name":"Keyboard Manager","version":"1"}
mykhailopylyp commented 3 years ago

@evoL Can you install the private build from the following zip file? Take into account that it is not signed. Before installing uninstall your current PowerToys application. PowerToysSetup-0.0.1-x64.zip

Then, reproduce the issue.

Then, open a command prompt and run "%PROGRAMFILES%\PowerToys\Tools\BugReportTool.exe" (the double quotes are important) that will create a zip file on you desktop named like this PowerToysReport_2021-01-04-12-02-08.zip You can drag and drop it in a GitHub comment.

yoonys commented 3 years ago

Same issue with my laptop, but no problem with my desktop (XPS 8930).

My laptop is similar to @evoL's.

I tried the followings and none of them helped.

I removed 0.29.3 and installed the private build as suggested by @mykhailopylyp, but when I open the PowerToys settings from the PowerToys icon from the taskbar, I see the following error message and I cannot open it.

image

evoL commented 3 years ago

I'm sorry, I'm afraid I can't test the debug build on that system anymore. I returned the laptop due to numerous other issues.

FYI, I tested 0.29.3 on another laptop and the issue doesn't occur there:

I'll check later if it occurs on a VM.

Edit: it doesn't occur when I installed 0.29.3 in a VM installed from the Dell recovery image. Sorry that I can't help further. :(

mykhailopylyp commented 3 years ago

@yoonys run "%PROGRAMFILES%\PowerToys\Tools\BugReportTool.exe" (the double quotes are important) that will create a zip file on you desktop named like this PowerToysReport_2021-01-04-12-02-08.zip You can drag and drop it in a GitHub comment.

yoonys commented 3 years ago

@mykhailopylyp Attached is the report. Note that I wasn't able to reproduce with the private build 0.0.1 because I cannot open PowerToys (see error above), but is still a problem in 0.29.3. The report is created using 0.0.1. Thanks for your help! PowerToysReport_2021-01-21-09-42-37.zip

mykhailopylyp commented 3 years ago

@yoonys

Make sure you have the private build installed.

UPD: You can back up settings.json file if you want to persist you PowerToys settings.

mykhailopylyp commented 3 years ago

@yoonys Can you update to 0.33.1 and check if you still can reproduce it?

yoonys commented 3 years ago

@mykhailopylyp Thanks for your help. I can still reproduce it with 0.33.1 and with up-to-date Windows 10 and Dell BIOS. Everything else including "Remap keys" works fine, and it's only when I click "+" button in "Remap shortcuts" that it crashes. Please let me know if I can provide any other information on my side.

mykhailopylyp commented 3 years ago

@yoonys Thank you for following up! Can you try the following steps:

yoonys commented 3 years ago

PowerToysReport_2021-03-10-16-01-28.zip

Here you are. PowerToys still crashes and closes when I click "+" button.

mykhailopylyp commented 3 years ago

@yoonys We have a possible fix. Can you install a test build below and verify if the issue is gone? https://github.com/mykhailopylyp/PowerToys/blob/issue-8693-testbuild/PowerToysSetup-0.0.1-x64-8693_1.exe If it is not gone upload the bug report, please.

yoonys commented 3 years ago

@mykhailopylyp Thanks for your help. It still crashes. Here's the report.

PowerToysReport_2021-03-13-14-46-04.zip

mykhailopylyp commented 3 years ago

@yoonys Thank you for helping us. Can you give a try https://github.com/mykhailopylyp/PowerToys/blob/issue-8693-testbuild/PowerToysSetup-0.0.1-x64-8693_2.exe and upload the report?

We are planning to make KBM a separate process in 0.37 so it would be a lot easier to debug it.

yoonys commented 3 years ago

@mykhailopylyp Still shutting down. Here's the report. I do think that this issue is only on certain Dell XPS laptops. I have no idea why...

PowerToysReport_2021-03-28-12-39-44.zip

mykhailopylyp commented 3 years ago

@yoonys Thank you for following up! Because the log file was trimmed it is still hard to say what is the issue. I think we will try to figure it out after #10127 is done.

enricogior commented 3 years ago

Moving to 0.37

thomassvensen commented 3 years ago

I also have this issue on my Dell Precision 5530, so I agree with @yoonys assumption that this problem is specific to Dell laptops. I just installed 0.35 and experience exactly what is described above.

enricogior commented 3 years ago

@evoL @thomassvensen can you please verify if this is still happening for you in 0.37? Thanks. https://github.com/microsoft/PowerToys/releases/download/v0.37.0/PowerToysSetup-0.37.0-x64.exe

yoonys commented 3 years ago

PowerToysReport_2021-04-29-15-53-55.zip

It behaves differently from previous versions, but still doesn't work properly. When I click "+" button, the "Remap shortcuts" window closes unexpectedly, instead of the whole PowerToys crashing (previous behavior).

enricogior commented 3 years ago

@yoonys the log doesn't show any crash. Can you check the Event Viewer under Windows Logs -> Application to verify if there is an error reported for PowerToys.KeyboardManagerEditor.exe?

yoonys commented 3 years ago

There is an error reported right after "Remap shortcuts" window crashes (PowerToys still running without crash).

It seems GitHub doesn't support .evtx file, so below are copies of two events that are created.

Event 1000, Application Error Log Name: Application Source: Application Error Date: 4/30/2021 2:25:02 PM Event ID: 1000 Task Category: (100) Level: Error Keywords: Classic User: N/A Computer: Yoseob-Yoon-XPS Description: Faulting application name: PowerToys.KeyboardManagerEditor.exe, version: 0.37.0.0, time stamp: 0x6089879d Faulting module name: KERNELBASE.dll, version: 10.0.19041.964, time stamp: 0x812662a7 Exception code: 0xc000027b Fault offset: 0x000000000010b39c Faulting process id: 0x64ac Faulting application start time: 0x01d73e0746c5acec Faulting application path: C:\Program Files\PowerToys\modules\KeyboardManager\KeyboardManagerEditor\PowerToys.KeyboardManagerEditor.exe Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll Report Id: 296de5ac-5344-4efb-be63-b83f5b7fa603 Faulting package full name: Faulting package-relative application ID: Event Xml:

1000 0 2 100 0 0x80000000000000 1155013 Application Yoseob-Yoon-XPS PowerToys.KeyboardManagerEditor.exe 0.37.0.0 6089879d KERNELBASE.dll 10.0.19041.964 812662a7 c000027b 000000000010b39c 64ac 01d73e0746c5acec C:\Program Files\PowerToys\modules\KeyboardManager\KeyboardManagerEditor\PowerToys.KeyboardManagerEditor.exe C:\WINDOWS\System32\KERNELBASE.dll 296de5ac-5344-4efb-be63-b83f5b7fa603 **Event 1001, Windows Error Reporting** Log Name: Application Source: Windows Error Reporting Date: 4/30/2021 2:25:03 PM Event ID: 1001 Task Category: None Level: Information Keywords: Classic User: N/A Computer: Yoseob-Yoon-XPS Description: Fault bucket 1853476054401154581, type 4 Event Name: APPCRASH Response: Not available Cab Id: 0 Problem signature: P1: PowerToys.KeyboardManagerEditor.exe P2: 0.37.0.0 P3: 6089879d P4: combase.dll P5: 10.0.19041.928 P6: c94441ae P7: 88000fa8 P8: 0000000000086256 P9: P10: Attached files: \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAEC0.tmp.mdmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAF6C.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAF8D.tmp.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAFAA.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAFCA.tmp.txt These files may be available here: \\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_PowerToys.Keyboa_c82646cc20e77ed6707d7271b8738bec114ff7ae_a166e24f_b7a98b47-b41d-4cbc-b9cc-371ec1a6f6db Analysis symbol: Rechecking for solution: 0 Report Id: 296de5ac-5344-4efb-be63-b83f5b7fa603 Report Status: 268435456 Hashed bucket: 82120580fe4fc5b2b9b8dea6be45fe15 Cab Guid: 0 Event Xml: 1001 0 4 0 0 0x80000000000000 1155014 Application Yoseob-Yoon-XPS 1853476054401154581 4 APPCRASH Not available 0 PowerToys.KeyboardManagerEditor.exe 0.37.0.0 6089879d combase.dll 10.0.19041.928 c94441ae 88000fa8 0000000000086256 \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAEC0.tmp.mdmp \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAF6C.tmp.WERInternalMetadata.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAF8D.tmp.xml \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAFAA.tmp.csv \\?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERAFCA.tmp.txt \\?\C:\ProgramData\Microsoft\Windows\WER\ReportArchive\AppCrash_PowerToys.Keyboa_c82646cc20e77ed6707d7271b8738bec114ff7ae_a166e24f_b7a98b47-b41d-4cbc-b9cc-371ec1a6f6db 0 296de5ac-5344-4efb-be63-b83f5b7fa603 268435456 82120580fe4fc5b2b9b8dea6be45fe15 0
enricogior commented 3 years ago

Note to dev. The global exception handler didn't catch this exception, we should try https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/set-se-translator

ghost commented 3 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 5 days. It will be closed if no further activity occurs within 5 days of this comment.

ghost commented 3 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 5 days. It will be closed if no further activity occurs within 5 days of this comment.

ghost commented 3 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 5 days. It will be closed if no further activity occurs within 5 days of this comment.

ridesky commented 3 years ago

same issue

laptop: MSI ge76 i9 11980hk

schancksb commented 3 years ago

Same issue here

PowerToysReport_2021-07-06-14-29-43.zip

mykhailopylyp commented 3 years ago

Cabs are absent in the Watson for PowerToysReport_2021-07-06-14-29-43

dedavis6797 commented 3 years ago

@jaimecbernardo @mykhailopylyp What's the status of this? Does it make sense to keep pushing on it in 0.45, or are we blocked on something?

jaimecbernardo commented 3 years ago

My understanding is that this is hard to replicate, but it seems to still be occurring: https://github.com/microsoft/PowerToys/issues/12575 https://github.com/microsoft/PowerToys/issues/12656

Cabs seemed to be missing in watson when this error was picked up there:

Cabs are absent in the Watson for PowerToysReport_2021-07-06-14-29-43

It might make sense to revisit this and see if they were picked up on watson for any of the recent reports @mykhailopylyp

jaimecbernardo commented 3 years ago

What I seem to notice is that all the machines where this is happening recently are on the 19043 build number for Windows, patch 1110. I'll try to update a VM and see if I can replicate it.

jaimecbernardo commented 3 years ago

Hi @ridesky and @seba5496 ,

I still haven't been able to reproduce this error on my machines. Could you please send a dump file?

One way of achieving this would be by creating an entry in the Registry Editor (regedit.msc), for Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\PowerToys.KeyboardManagerEditor.exe , according to the instructions in https://docs.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps

It should look something like this in the end: image

After that, please replicate the bug, navigate to $LOCALAPPDATA%\CrashDumps in the File Explorer and upload the zipped PowerToysManagerEditor.exe.*.dmp file to a GitHub comment.

The idea is that this could show us the stack trace and help pinpoint what the issue might be.

trullock commented 3 years ago

Also got this exact problem with 0.43.0 after fresh install. Got all the latest .NET SDKs installed.

Windows 10 21H1 19043.1165

Let me know what other useful info I can provide PowerToysReport_2021-08-17-12-27-07.zip

Crash dump as per @jaimecbernardo's instructions above

PowerToys.KeyboardManagerEditor.exe.8424.dmp.zip

jaimecbernardo commented 3 years ago

@trullock , Thanks for sending it.

Like in https://github.com/microsoft/PowerToys/issues/12575#issuecomment-899920775, the crash seems to be coming from XamlBridge::MessageLoop(): https://github.com/microsoft/PowerToys/blob/31a5d4924601dee117c53c7aa05f8b231407e0a1/src/modules/keyboardmanager/KeyboardManagerEditorLibrary/XamlBridge.cpp#L149

Can't seem to get much more information from here. At the time of calling it, it seems that the message is 96 (0x60). Tried to look into what this might be, but couldn't find this value for usual messages in Windows.

Do you by any chance use AutoHotKey or possibly other software that might be sending messages to other programs?

trullock commented 3 years ago

No autohotkey, however it's a Dell laptop which may have something proprietary installed. When I press Ctrl-Alt-U I get an accented u (on phone so can't replicate now). I'm assuming this is some Dell feature - I wanted to use this tool to turn it off so I can use the shortcut properly as pressing it only "sends" the accented u, it doesn't appear as a Ctrl-Alt-U. The keyboard shortcut list is empty before I press the +

jaimecbernardo commented 3 years ago

Additional information, the exception being handled seems to have the error code 0x802b0014 , which seems to be "Layout cycle detected".

jaimecbernardo commented 3 years ago

Hi @trullock ,

Could you please uninstall your current version of PowerToys and install this test build? (It's unsigned, by the way) The build removes the instruction that we suspect is triggering the crash.

https://github.com/jaimecbernardo/PowerToys/releases/tag/v0.0.2-no-shortcut-update-layout

Please verify if the crash still occurs. If if does, could you please send the generated crash dump?

Thank you, in advance.

trullock commented 3 years ago

This works 👍

jaimecbernardo commented 3 years ago

This works 👍

Thank you for verifying the crash no longer occurs, which is what I understood by your message 😄

trullock commented 3 years ago

Yes, apologies. No crashes, I can now click [+] on the keyboard shortcut remapper.

Thanks for fixing