metalbear-co / mirrord

Connect your local process and your cloud environment, and run local code in cloud conditions.
https://mirrord.dev
MIT License
3.75k stars 101 forks source link

Socket operation on non-socket on git clone cmd #2312

Open AvihaiSam opened 6 months ago

AvihaiSam commented 6 months ago

Bug Description

running on osX M1:

gh repo clone $REPO $PATH -- -c advice.detachedHead=false --quiet --depth 1 -b $BRANCH

and got the following output:

ERROR ThreadId(01) mirrord_layer::error: Error occured in Layer >> ProxyError(CodecError(IoError(Os { code: 38, kind: Uncategorized, message: “Socket operation on non-socket” })))
gethostname: Invalid argument

Steps to Reproduce

gh repo clone $REPO $PATH -- -c advice.detachedHead=false --quiet --depth 1 -b $BRANCH

Backtrace

No response

Relevant Logs

No response

Your operating system and version

osX, M1

Local process

the code runs inside bash script

Local process version

-

Additional Info

mirrord vr: 3.92.0

AvihaiSam commented 6 months ago

trace logs of agent mirrord-agent.log

meowjesty commented 6 months ago

I've tried looking into this (on linux) and could not reproduce this error IoError(Os { code: 38, kind: Uncategorized, message: “Socket operation on non-socket” } exactly. Instead, what I'm getting is a hard crash:

remote_hostname_string:remote_open: mirrord_layer::file::ops: peer_addr [Err(Os { code: 9, kind: Uncategorized, message: "Bad file descriptor" })], local_addr [Err(Os { code: 9, kind: Uncategorized, message: "Bad file descriptor" })] path="/etc/hostname" open_options=OpenOptionsInternal { read: true, write: false, append: false, truncate: false, create: false, create_new: false }

Which indicates that the internal proxy socket is being closed/dropped (even when I tried unsetting O_CLOEXEC), both before and after adding an execve hook. The end result is the same, gh repo clone doesn't work.

I've made a small sample app that reproduces the issue here. It executes curl using a golang Command.

gh-cli is written in go, so this looks like a mirrord-go issue, I've tried simulating this with a rust sample (start a process and run git clone) and it just worked, meanwhile the go sample is unreliable, sometimes it works, most of the time it doesn't.

I'm dropping this for now, if someone else wants to investigate it on macos, would appreciate (maybe it's a different issue on macos?).