Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash when connecting to VM #3172

Closed
shenki opened this issue Jan 29, 2025 · 4 comments
Closed

crash when connecting to VM #3172

shenki opened this issue Jan 29, 2025 · 4 comments

Comments

@shenki
Copy link

shenki commented Jan 29, 2025

Description

When I added a snippet to ~/.lima/default/lima.yml and tried to connect:

$ lima --version
limactl version 1.0.4
$ lima
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x80 pc=0x10351e494]

goroutine 1 [running]:
main.shellAction(0x14000156c08, {0x14000114ed0?, 0x4?, 0x103537de5?})
	/private/tmp/lima-20250121-4853-uuipyh/lima-1.0.4/cmd/limactl/shell.go:90 +0x3c4
github.com/spf13/cobra.(*Command).execute(0x14000156c08, {0x14000114ea0, 0x1, 0x1})
	/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0x834
github.com/spf13/cobra.(*Command).ExecuteC(0x14000156008)
	/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/brew/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1041
main.main()
	/private/tmp/lima-20250121-4853-uuipyh/lima-1.0.4/cmd/limactl/main.go:28 +0x20

The snippet I added was:

ssh:
- forwardAgent: true

I (now) realise the syntax is incorrect, but it would be better if the tool didn't crash

@AkihiroSuda
Copy link
Member

Thanks for the report.
Seems a duplicate of #3103

@jandubois
Copy link
Member

@shenki Can you please show the exact change you made? I cannot reproduce the problem; it always gets caught by YAML validation:

If I simply add the snippet:

FATA[0023] failed to unmarshal YAML (main file "/Users/jan/.lima/default/lima.yaml"): [145:1] mapping key "ssh" already defined at [7:1]
> 145 | ssh:
        ^
  146 |   # A localhost port of the host. Forwarded to port 22 of the guest.
  147 |   # 🟢 Builtin default: 0 (automatically assigned to a free port)
  148 |   # NOTE: when the instance name is "default", the builtin default value is set to
  149 |

If I add the snippet under the existing ssh key:

FATA[0029] failed to unmarshal YAML (main file "/Users/jan/.lima/default/lima.yaml"): [162:3] mapping key "forwardAgent" already defined at [145:3]
  159 |   # Set the environment variable `SSH_AUTH_SOCK` value to the path above.
  160 |   # The socket is accessible by the non-root user inside the Lima instance.
  161 |   # 🟢 Builtin default: false
> 162 |   forwardAgent: null
          ^
  163 |   # Forward X11 into the instance
  164 |   # 🟢 Builtin default: false
  165 |   forwardX11: null
  166 |

If I replace the existing ssh key and everything below it:

FATA[0028] failed to unmarshal YAML (main file "/Users/jan/.lima/default/lima.yaml"): [145:1] sequence was used where mapping is expected
  144 | ssh:
> 145 | - forwardAgent: true
        ^
  147 | caCerts:
  148 |   # If set to `true`, this will remove all the default trusted CA certificates that
  149 |

@shenki
Copy link
Author

shenki commented Jan 30, 2025

This was my yaml before:

# This template requires Lima v0.7.0 or later
images:
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-amd64-daily.qcow2"
  arch: "x86_64"
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-arm64-daily.qcow2"
  arch: "aarch64"
mountTypesUnsupported: ["9p"]
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
memory: 16GiB
cpus: 14

Here it is after:

# This template requires Lima v0.7.0 or later
images:
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-amd64-daily.qcow2"
  arch: "x86_64"
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-arm64-daily.qcow2"
  arch: "aarch64"
mountTypesUnsupported: ["9p"]
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
memory: 16GiB
cpus: 14
ssh:
 forwardAgent: true

I wasn't aware that limactl edit existed, so I was editing the file and then running lima. The vm was running the entire time, as I was unaware that I needed to stop and start the vm, but just running lima was enough to parse the yaml and trigger the crash.

@jandubois
Copy link
Member

jandubois commented Jan 30, 2025

I still can't get it to fail for me. I copied the "after" version to the clipboard and then ran:

pbpaste > test.yamllimactl --version
limactl version 1.0.4-23-gdc02547flimactl start --tty=false --name default --vm-type qemu test.yaml
INFO[0000] Terminal is not available, proceeding without opening an editor
INFO[0000] Starting the instance "default" with VM driver "qemu"
INFO[0000] QEMU binary "/opt/homebrew/bin/qemu-system-aarch64" seems properly signed with the "com.apple.security.hypervisor" entitlement
INFO[0000] Attempting to download the image              arch=aarch64 digest= location="https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-arm64-daily.qcow2"
INFO[0001] Using cache "/Users/jan/Library/Caches/lima/download/by-url-sha256/0c2d4a4643f39c0f18efc12f672c423ecbb6816bb0cb5d3d1d78f008fbe72354/data"
INFO[0001] Attempting to download the nerdctl archive    arch=aarch64 digest="sha256:2a97f78e14cb3e024068d936c8fb801365981e5b48577e278907079de47e4d2c" location="https://github.com/containerd/nerdctl/releases/download/v2.0.3/nerdctl-full-2.0.3-linux-arm64.tar.gz"
INFO[0001] Using cache "/Users/jan/Library/Caches/lima/download/by-url-sha256/c6ebad532b2f0562fcaf9a509f21375c20a44ed3c148c4ad1847bd06107f375f/data"
INFO[0002] [hostagent] hostagent socket created at /Users/jan/.lima/default/ha.sock
INFO[0002] [hostagent] Using system firmware ("/opt/homebrew/share/qemu/edk2-aarch64-code.fd")
INFO[0002] [hostagent] Starting QEMU (hint: to watch the boot progress, see "/Users/jan/.lima/default/serial*.log")
INFO[0002] SSH Local Port: 60022
INFO[0002] [hostagent] Waiting for the essential requirement 1 of 4: "ssh"
INFO[0019] [hostagent] Waiting for the essential requirement 1 of 4: "ssh"
INFO[0019] [hostagent] The essential requirement 1 of 4 is satisfied
INFO[0019] [hostagent] Waiting for the essential requirement 2 of 4: "user session is ready for ssh"
INFO[0019] [hostagent] The essential requirement 2 of 4 is satisfied
INFO[0019] [hostagent] Waiting for the essential requirement 3 of 4: "sshfs binary to be installed"
INFO[0022] [hostagent] The essential requirement 3 of 4 is satisfied
INFO[0022] [hostagent] Waiting for the essential requirement 4 of 4: "fuse to \"allow_other\" as user"
INFO[0025] [hostagent] The essential requirement 4 of 4 is satisfied
INFO[0025] [hostagent] Mounting "/Users/jan" on "/Users/jan"
INFO[0025] [hostagent] Mounting "/tmp/lima" on "/tmp/lima"
INFO[0025] [hostagent] Waiting for the optional requirement 1 of 2: "systemd must be available"
INFO[0025] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/Users/jan/.lima/default/ga.sock" (host)
INFO[0025] [hostagent] The optional requirement 1 of 2 is satisfied
INFO[0025] [hostagent] Guest agent is running
INFO[0025] [hostagent] Waiting for the optional requirement 2 of 2: "containerd binaries to be installed"
INFO[0025] [hostagent] Not forwarding TCP 0.0.0.0:22
INFO[0025] [hostagent] Not forwarding TCP 127.0.0.53:53
INFO[0025] [hostagent] Forwarding TCP from 0.0.0.0:5355 to 127.0.0.1:5355
INFO[0025] [hostagent] Not forwarding TCP 127.0.0.54:53
INFO[0025] [hostagent] Not forwarding TCP [::]:22
INFO[0025] [hostagent] Forwarding TCP from [::]:5355 to 127.0.0.1:5355
WARN[0025] [hostagent] failed to set up forwarding tcp port 5355 (negligible if already forwarded)  error="failed to run [ssh -F /dev/null -o IdentityFile=\"/Users/jan/.lima/_config/user\" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers=\"^[email protected],[email protected]\" -o User=jan -o ControlMaster=auto -o ControlPath=\"/Users/jan/.lima/default/ssh.sock\" -o ControlPersist=yes -o ForwardAgent=yes -T -O forward -L 127.0.0.1:5355:[::]:5355 -N -f -p 60022 127.0.0.1 --]: \"\": exit status 255"
INFO[0028] [hostagent] The optional requirement 2 of 2 is satisfied
INFO[0028] [hostagent] Waiting for the guest agent to be running
INFO[0028] [hostagent] Waiting for the final requirement 1 of 1: "boot scripts must have finished"
INFO[0031] [hostagent] Forwarding TCP from 127.0.0.1:33161 to 127.0.0.1:33161
INFO[0040] [hostagent] The final requirement 1 of 1 is satisfied
INFO[0041] READY. Run `lima` to open the shell.cat ~/.lima/default/lima.yaml
# This template requires Lima v0.7.0 or later
images:
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-amd64-daily.qcow2"
  arch: "x86_64"
- location: "https://cloud.debian.org/images/cloud/trixie/daily/latest/debian-13-genericcloud-arm64-daily.qcow2"
  arch: "aarch64"
mountTypesUnsupported: ["9p"]
mounts:
- location: "~"
- location: "/tmp/lima"
  writable: true
memory: 16GiB
cpus: 14
ssh:
  forwardAgent: true
vmType: qemulima
jan@lima-default:/Users/jan$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants