mame/wsl2-ssh-agent

Exception "Value connot be null"

derekmpage opened this issue · 4 comments

I receive an exception when trying to run this utility.

note I am using ssh certificates.

me@wsl2_host ~/cat .zshrc | grep wsl2
eval $($HOME/wsl2-ssh-agent)

Do you have any idea what's happening here?

 me@wsl2_host$ ~/ ./wsl2-ssh-agent --verbose --foreground
[L] 2024/03/26 16:30:22 start listening on /home/me/.ssh/wsl2-ssh-agent.sock
[L] 2024/03/26 16:30:22 invoking [W] in PowerShell.exe
[W] 2024/03/26 16:30:23 ssh-agent.exe version: 8.6.0.1 (ignoreOpenSSHExtensions: True)
[L] 2024/03/26 16:30:23 [W] invoked successfully
[W] 2024/03/26 16:30:23 ready: PSVersion 5.1.22621.2506
[L] 2024/03/26 16:30:28 ssh: connected
[L] 2024/03/26 16:30:28 ssh -> [L] (5 B)
[L] 2024/03/26 16:30:28 [L] -> [W] (5 B)
[W] 2024/03/26 16:30:28 [W] named pipe: connected
[W] 2024/03/26 16:30:28 [L] -> [W] -> ssh-agent.exe (5 B)
[L] 2024/03/26 16:30:28 [L] <- [W] (9 B)
[L] 2024/03/26 16:30:28 ssh <- [L] (9 B)
[W] 2024/03/26 16:30:28 [L] <- [W] <- ssh-agent.exe (9 B)
[W] 2024/03/26 16:30:28 [W] named pipe: disconnected
[L] 2024/03/26 16:30:42 ssh -> [L] (747 B)
[L] 2024/03/26 16:30:42 [L] -> [W] (747 B)
[W] 2024/03/26 16:30:42 [W] named pipe: connected
[W] 2024/03/26 16:30:42 [L] -> [W] -> ssh-agent.exe (747 B)
[W] 2024/03/26 16:30:42 [W] named pipe: disconnected
wsl2-ssh-agent.ps1: terminated
Exception calling "Write" with "3" argument(s): "Value cannot be null.
Parameter name: buffer"
At line:33 char:5
+                 $ssh_client_out.Write($buf, 0, $buf.Length)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

[L] 2024/03/26 16:30:52 failed to read from [W]: read |0: i/o timeout
[L] 2024/03/26 16:30:52 [W] terminated; retry
[L] 2024/03/26 16:30:52 invoking [W] in PowerShell.exe
[W] 2024/03/26 16:30:53 ssh-agent.exe version: 8.6.0.1 (ignoreOpenSSHExtensions: True)
[L] 2024/03/26 16:30:53 [W] invoked successfully
[L] 2024/03/26 16:30:53 [L] -> [W] (747 B)
[W] 2024/03/26 16:30:53 ready: PSVersion 5.1.22621.2506
[W] 2024/03/26 16:30:53 [W] named pipe: connected
[W] 2024/03/26 16:30:53 [L] -> [W] -> ssh-agent.exe (747 B)
[W] 2024/03/26 16:30:53 [W] named pipe: disconnected
wsl2-ssh-agent.ps1: terminated
Exception calling "Write" with "3" argument(s): "Value cannot be null.
Parameter name: buffer"
At line:33 char:5
+                 $ssh_client_out.Write($buf, 0, $buf.Length)
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException
mame commented

@Hill-98 Could you please check this out? Looks like ReadMessage returns null, but I don't see how that could happen. TBH I'm not familiar enough with PowerShell.

I'm not familiar too, but my guess is that it might be because there was an error in ReadMessage, but PowerShell doesn't abort by default when it encounters an error, so $buf gets a null.

mame commented

@derekmpage Can you try 0.9.2 (the older version) of wsl2-ssh-agent?

https://github.com/mame/wsl2-ssh-agent/releases/tag/v0.9.2

If the problem is not reproduced there, I suspect it is caused by the changes in #7. I guess I'll just have to revert.

mame commented

No reply, so I'll close it for now. If you find that the issue does not reproduce with 0.9.2, please let me know.