microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.26k stars 812 forks source link

explorer.exe always return 1 regardless the result #6565

Open patrick330602 opened 3 years ago

patrick330602 commented 3 years ago

Environment

Windows build number: 21313
Your Distribution version: Ubuntu 20.04.1 LTS/Ubuntu Hirsute Hippo (Development Branch)
Whether the issue is on WSL 2 and/or WSL 1: WSL1/WSL2

Steps to reproduce

type explorer.exe https://github.com.

WSL logs:

Click to expand ``` execve("/mnt/c/WINDOWS/explorer.exe", ["explorer.exe", "https://google.com"], 0x7ffc177fbc68 /* 32 vars */) = 0 arch_prctl(ARCH_SET_FS, 0x34fb90) = 0 set_tid_address(0x34fbc8) = 27638 brk(NULL) = 0x1773000 brk(0x1774000) = 0x1774000 gettid() = 27638 gettid() = 27638 gettid() = 27638 gettid() = 27638 sched_getaffinity(0, 128, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) = 32 brk(0x1775000) = 0x1775000 getpid() = 27638 getcwd("/home/patrick/wslu", 4096) = 19 uname({sysname="Linux", nodename="PkWnMcBk", ...}) = 0 getcwd("/home/patrick/wslu", 4096) = 19 open("/mnt/c/WINDOWS/explorer.exe", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_PATH) = 3 readlink("/proc/self/fd/3", "/mnt/c/WINDOWS/explorer.exe", 4095) = 27 fstat(3, {st_mode=S_IFREG|0544, st_size=5136424, ...}) = 0 stat("/mnt/c/WINDOWS/explorer.exe", {st_mode=S_IFREG|0544, st_size=5136424, ...}) = 0 close(3) = 0 open("/proc/self/mountinfo", O_RDONLY) = 3 readv(3, [{iov_base="", iov_len=0}, {iov_base="39 27 8:16 / / rw,relatime - ext"..., iov_len=1024}], 2) = 1024 readv(3, [{iov_base="", iov_len=0}, {iov_base="tmpfs rw,mode=755\n52 51 0:31 / /"..., iov_len=1024}], 2) = 1024 readv(3, [{iov_base="", iov_len=0}, {iov_base="elatime - cgroup cgroup rw,net_p"..., iov_len=1024}], 2) = 1024 readv(3, [{iov_base="", iov_len=0}, {iov_base="a;uid=1000;gid=1000;umask=0022;f"..., iov_len=1024}], 2) = 112 readv(3, [{iov_base="", iov_len=0}, {iov_base="", iov_len=1024}], 2) = 0 close(3) = 0 getcwd("/home/patrick/wslu", 4096) = 19 open("/proc/self/mountinfo", O_RDONLY) = 3 readv(3, [{iov_base="", iov_len=0}, {iov_base="39 27 8:16 / / rw,relatime - ext"..., iov_len=1024}], 2) = 1024 readv(3, [{iov_base="", iov_len=0}, {iov_base="tmpfs rw,mode=755\n52 51 0:31 / /"..., iov_len=1024}], 2) = 1024 readv(3, [{iov_base="", iov_len=0}, {iov_base="elatime - cgroup cgroup rw,net_p"..., iov_len=1024}], 2) = 1024 brk(0x1776000) = 0x1776000 readv(3, [{iov_base="", iov_len=0}, {iov_base="a;uid=1000;gid=1000;umask=0022;f"..., iov_len=1024}], 2) = 112 readv(3, [{iov_base="", iov_len=0}, {iov_base="", iov_len=1024}], 2) = 0 close(3) = 0 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(2, TCGETS, {B38400 opost isig icanon echo ...}) = 0 ioctl(0, TIOCGPGRP, [27635]) = 0 getpgid(0) = 27635 fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0 fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0 fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0 ioctl(0, TIOCGWINSZ, {ws_row=30, ws_col=120, ws_xpixel=0, ws_ypixel=0}) = 0 ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 -opost -isig -icanon -echo ...}) = 0 dup(0) = 3 socket(AF_VSOCK, SOCK_STREAM|SOCK_CLOEXEC, 0) = 4 bind(4, {sa_family=AF_VSOCK, sa_data="\0\0\377\377\377\377\377\377\377\377\0\0\0\0"}, 16) = 0 getsockname(4, {sa_family=AF_VSOCK, sa_data="\0\0\336\255nX\377\377\377\377\0\0\0\0"}, [16]) = 0 listen(4, 4) = 0 socket(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0) = 5 connect(5, {sa_family=AF_UNIX, sun_path="/run/WSL/10_interop"}, 110) = 0 write(5, "\6\0\0\0007\1\0\0\336\255nX\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 311) = 311 poll([{fd=4, events=POLLIN}], 1, 10000) = 1 ([{fd=4, revents=POLLIN}]) accept4(4, {sa_family=AF_VSOCK, sa_data="\0\0\313\214\2\216\2\0\0\0\0\0\0\0"}, [16], SOCK_CLOEXEC) = 6 poll([{fd=4, events=POLLIN}], 1, 10000) = 1 ([{fd=4, revents=POLLIN}]) accept4(4, {sa_family=AF_VSOCK, sa_data="\0\0\314\214\2\216\2\0\0\0\0\0\0\0"}, [16], SOCK_CLOEXEC) = 7 poll([{fd=4, events=POLLIN}], 1, 10000) = 1 ([{fd=4, revents=POLLIN}]) accept4(4, {sa_family=AF_VSOCK, sa_data="\0\0\315\214\2\216\2\0\0\0\0\0\0\0"}, [16], SOCK_CLOEXEC) = 8 poll([{fd=4, events=POLLIN}], 1, 10000) = 1 ([{fd=4, revents=POLLIN}]) accept4(4, {sa_family=AF_VSOCK, sa_data="\0\0\316\214\2\216\2\0\0\0\0\0\0\0"}, [16], SOCK_CLOEXEC) = 9 close(4) = 0 rt_sigprocmask(SIG_BLOCK, [INT WINCH], NULL, 8) = 0 signalfd4(-1, [INT WINCH], 8, 0) = 4 poll([{fd=0, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=4, events=POLLIN}], 5, -1) = 1 ([{fd=9, revents=POLLIN}]) recvfrom(9, "\t\0\0\0 \0\0\0", 8, MSG_WAITALL, NULL, NULL) = 8 recvfrom(9, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0\0\0\0\0\0", 24, 0, NULL, NULL) = 24 ioctl(3, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo ...}) = 0 close(3) = 0 poll([{fd=0, events=POLLIN}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=9, events=POLLIN}, {fd=4, events=POLLIN}], 5, -1) = 1 ([{fd=9, revents=POLLIN}]) recvfrom(9, "\7\0\0\0\f\0\0\0", 8, MSG_WAITALL, NULL, NULL) = 8 recvfrom(9, "\1\0\0\0", 4, 0, NULL, NULL) = 4 shutdown(6, SHUT_WR) = 0 poll([{fd=-1}, {fd=7, events=POLLIN}, {fd=8, events=POLLIN}, {fd=-1}, {fd=-1}], 5, -1) = 2 ([{fd=7, revents=POLLIN}, {fd=8, revents=POLLIN}]) read(7, "", 4096) = 0 read(8, "", 4096) = 0 shutdown(6, SHUT_WR) = 0 close(4) = 0 close(5) = 0 close(9) = 0 close(8) = 0 close(7) = 0 close(6) = 0 exit_group(1) = ? +++ exited with 1 +++ ```

Expected behavior

The process exits with 0 and opens the GitHub website.

Actual behavior

The process exits with 1 and opens the GitHub website. image

therealkenc commented 3 years ago

Thanks for the strace log; appreciated. Was able to reproduce here. The exit code of 1 appears to be confined to Windows apps. Console apps which succeed return 0.

It is probably better to launch Windows apps is via PowerShell. That explorer.exe app hasn't exited and doesn't have an exit code. But regardless, interop shouldn't be presenting a nonzero exit code unless (say) the path wasn't found or similar.

image

DHowett commented 3 years ago

Curious- what do you get if you run explorer from cmd (without WSL being in the picture at all) and then check %ERRORLEVEL%?

therealkenc commented 3 years ago

%ERRORLEVEL% is not affected by explorer.exe. The variable is left as its previous value.

image

martin-braun commented 7 months ago

The most simplest things to expect don't work as they should. Better invest more into AI, who cares about the exit code of explorer.exe ...