canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.95k stars 651 forks source link

Bad unicode handling on Windows #1314

Open samlopezic opened 4 years ago

samlopezic commented 4 years ago

Trying to execute multipass GUI does nothing. Also from PowerShell any command related doesn't work.

multipass help

Return to the prompt and no output is sent.

In Windows event viewer the error are related with ucrtbase.dll

Nombre de la aplicación con errores: multipass.gui.exe, versión: 0.0.0.0, marca de tiempo: 0x5df97ce4 Nombre del módulo con errores: ucrtbase.dll, versión: 10.0.18362.387, marca de tiempo: 0x4361b720 Código de excepción: 0xc0000409

Windows 10 Pro 1909 12-12-2019 Compilation 18363.592 Hyper-V Enabled

ricab commented 4 years ago

Hi @samlopezic

Could you please try uninstalling and reinstalling this version (if you can download again in case your earlier installer got corrupted)? And, before closing the installer, could you please click on the "details" button while the installer is running to view the install log, and attach it here?

Can you see the multipass daemon running in the services, or does it also fail to start? Is that the only error you see in the event log? That one concerns the GUI, but multipass also includes the command line client and the daemon. Do any of the errors say the path where ucrtbase.dll is being picked up from? Any other messages you could share with us, even if only warning/info/debug?

samlopezic commented 4 years ago

Hi @ricab

Before uninstalling/reinstalling i've checked the service and the information says [service_main] service is running Other events related to the service are:

[rpc] gRPC listening on localhost:50051, SSL:on

[Qt] QIODevice::write (QFile, "C:\Windows\system32\config\systemprofile\AppData\Local\multipassd\cache\vault\multipassd-image-records.json"): device not open

[url downloader] Cannot retrieve last modified date for https://multipass.run/static/latest-release.json: Host multipass.run not found. Using cached data instead.

Both multipass.gui.exe and multipass.exe throws error related with ucrtbase.dll Ruta de acceso del módulo con errores: C:\Windows\System32\ucrtbase.dll

I've attached the logs but the install was a difficult one. The details page not remain open and change to final page so is not easy copy the details, but i think is almost complete. In the other hand uninstallation details can be easily copied.

install.log uninstall.log

ricab commented 4 years ago

Thanks, the install log looks good.

[url downloader] Cannot retrieve last modified date for https://multipass.run/static/latest-release.json: Host multipass.run not found. Using cached data instead.

This message means that multipass failed to retrieve update data, and I wonder if it is feeding some junk to clients that they don't handle well. I tried a few things but so far I could not reproduce.

If you restart the multipass service, do you always get the multipass.run error in the log? And if you stop the service completely and then run multipass help, do you still get the same crash? What does $LASTEXITCODE say after that (in powershell)? BTW, is this all the same in cmd and an Admin PS?

samlopezic commented 4 years ago

Answering your questions:

Thank you.

ricab commented 4 years ago

Thanks for the report. I am afraid I did not find any clue in there, except maybe the version mismatch below.

multipass help does not need to contact the daemon, it should work without it. So the failure getting update data is unrelated to this.

Exception 0xc0000409 means stack buffer overflow, which is apparently not the same as stack overflow. It seems it is designed not to give any more information for security reasons. The return code matches that:

$ python -c 'print hex(2**30-1073740791)'
0x409

This could be a problem with multipass in some elusive corner case that we can't reproduce or it could be an issue with your system (in particular the dll where the problem occurs). multipass help does not execute a whole lot of code, and I have never seen anything like this, so I would not discard a system issue. The mismatch between the versions of the dll (10.0.18362.387) and the OS (10.0.18362.592) could also be clue.

Do you have other errors when using your pc? Any other faulty applications, strange errors poping up?

I am going to discuss this a bit internally. Meanwhile, here are a few of things you could try:

ricab commented 4 years ago

A couple more things that could be worth trying:

samlopezic commented 4 years ago

Yeah, i think it's something with my system. As developer i tend to install plenty of tools (Docker, some Visual Studio versions, Virtual Machines, etc.) and some of them could be the culprit. Multipass was another tool that get my attention but the final purpose was setting up a devops workflow with k8s on Ubuntu.

The version mismatch also could be because my machine came with W10 Home and later upgraded to W10 Pro but not clean install. Aditionally, in some forums i've read that ucrtbase.dll errors can be related to Microsoft Visual C++ versions installed on the machine. Maybe i could try install/reinstall some specific version that Multipass was developed on.

I'll try some of your suggestions and report back but if none other users are reporting this better to wait until next version and give it a try or reinstall my system, i'll do it but not soon :)

Thank you for your support, you can close the issue if you like.

ricab commented 4 years ago

OK, yeah please do let us know if you find anything else about this.

The visualcpp we use if you want to try it: https://chocolatey.org/packages/visualcpp-build-tools

I will keep this open for a while, in case someone else experiences the same thing.

samlopezic commented 4 years ago

Hi again, Finally i've got it running. I was working with docker volumes and it seems that my local username was causing trouble in CLI C:\Users\Samuel López\ so i've created a new account C:\Users\Developer\ and after login the multipass notification icon appears (totally unexpected). To be sure, opened PS and ran multipass help and that works too.

Saviq commented 4 years ago

Thanks @samlopezic, that's great, and something that will guide us to a fix!

Saviq commented 4 years ago

I got a dump out from the crash, attached are the dump itself plus an analysis from WinDbg:

multipass.exe.7804.zip multipass.txt

Saviq commented 4 years ago

I got some more data out of a debug build. multipass.exe.5300.txt multipass.exe.5300.zip multipass.gui.exe.5128.txt multipass.gui.exe.5128.zip

Ged-fi commented 4 years ago

Hi again, Finally i've got it running. I was working with docker volumes and it seems that my local username was causing trouble in CLI C:\Users\Samuel López\ so i've created a new account C:\Users\Developer\ and after login the multipass notification icon appears (totally unexpected). To be sure, opened PS and ran multipass help and that works too.

Confirmed - the multipass.exe binary does not handle non-ASCII characters in the username "USERPROFILE" variable correctly. As a temporary workaround, the user can try to set USERPROFILE to the legacy 8.3 equivalent path name, but multipass.exe should really use appropriate unicode functions for processing the path components.

Ged-fi commented 4 years ago

The same issue also affects multipassd - mounting the users home directory into 'primary:Home' fails if the user's profile in Windows resides in a folder that uses non-ASCII characters. The root cause is most likely incorrect character encoding when using Windows paths in the API - windows paths are Unicode, not utf-8.

zielinskila commented 4 years ago

Are there any editable settings I could change/modify to avoid that problem (without running 'multipass' from terminal which throws error even with 'multipass help')?

Windows 10 (with Microsoft Account) forced my user's unicode name (I'll never chose it consciously - as i'm from the dinosaur era when you've been used to name everything without spaces and latin-only characters), and usually (in other software) I could bypass it by using symlink path in settings (without unicode chars) to my user's folder (VirtualBox, Vagrant had this problem too and the symlink helped). Creating new Win10 username account for other reason than to just seeing it works makes no sense as I have all other things configured and prepared for my current user...

Ged-fi commented 4 years ago

@zielinskila did you try the workaround of setting "USERPROFILE" to the legacy 8.3 path name of your userprofile before launching multipass?

zielinskila commented 4 years ago

@Ged-fi no I didn't. How can I modify it?

Ged-fi commented 3 years ago

This issue still persists in version 1.8.0.

hughwang-me commented 2 years ago

I have get the same problem on windows 10 , error log is

[error] [client] Caught an unhandled exception: failed to open file 'C:/Users/杜骏骅/AppData/Roaming/multipass/client-certificate/multipass_cert_key.pem': Illegal byte sequence(42)

it is about chinese char .

i work fine on my mac os .

Ged-fi commented 2 years ago

@Saviq this one really should get assigned and fixed. Multipass should translate utf-8 to unicode and use the unicode native APIs on Windows.

Ged-fi commented 2 years ago

@Saviq Update: This can be fixed by enabling the utf-8 code page support in the application manifest. Or by enabling the (beta) utf-8 code page for non-unicode programs. This is done in the Windows 10/11 region settings.

UTF-8 in the Windows API

Ged-fi commented 2 years ago

@Saviq Update: This can be fixed by enabling the utf-8 code page support in the application manifest. Or by enabling the (beta) utf-8 code page for non-unicode programs. This is done in the Windows 10/11 region settings.

UTF-8 in the Windows API

Unfortunately the joy was premature - there seems to be some dependencies that still prevent multipass from correctly connecting to the instances spun up. So it's possible to start instances, but not to actually use them for anything.

Ged-fi commented 1 year ago

@Saviq Any chance of getting this under work eventually? This really prevents Multipass from working in many international environments.

ffkraemer commented 1 year ago

Unfortunately, it seems impossible to have Multipass on machine whose username has non-ASCII characters (like Latin accents). Are there plans to fix it in any new releases?