NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

lima fault when using docker template with go < 1.23.0 #339296

Open gdw2vs opened 2 months ago

gdw2vs commented 2 months ago

Describe the bug

When running limactl with the docker template, I get a "segmentation violation" (see Screenshots below)

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install the latest lima package from unstable (0.22.0)
  2. Create a VM (see screenshot section below)

Expected behavior

VM should be created successfully.

Screenshots

Full output:

$ limactl create --name default template://docker
? Creating an instance "default" Proceed with the current configuration
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x840df3]

goroutine 1 [running]:
github.com/lima-vm/lima/pkg/limayaml.executeGuestTemplate({0xc000128a10, 0x5e}, {0xc000112030, 0x1b})
        github.com/lima-vm/lima/pkg/limayaml/defaults.go:749 +0x193
github.com/lima-vm/lima/pkg/limayaml.FillDefault(0xc000130008, 0xc000130288, 0xc000130508, {0xc000112030, 0x25})
        github.com/lima-vm/lima/pkg/limayaml/defaults.go:403 +0x1ecb
github.com/lima-vm/lima/pkg/limayaml.Load({0xc0005ed000, 0xe56, 0x1000}, {0xc000112030, 0x25})
        github.com/lima-vm/lima/pkg/limayaml/load.go:89 +0x525
main.createInstance({0x1377678, 0x2202ca0}, 0xc000621b98, 0x1)
        github.com/lima-vm/lima/cmd/limactl/start.go:326 +0x1c5
main.loadOrCreateInstance(0xc000466c08, {0xc0004e91a0?, 0x0?, 0x0?}, 0x1)
        github.com/lima-vm/lima/cmd/limactl/start.go:278 +0x1778
main.createAction(0xc000466c08, {0xc0004e91a0, 0x1, 0x3})
        github.com/lima-vm/lima/cmd/limactl/start.go:479 +0x6c
github.com/spf13/cobra.(*Command).execute(0xc000466c08, {0xc0004e9110, 0x3, 0x3})
        github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc000466908)
        github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra@v1.8.0/command.go:1039
main.main()
        github.com/lima-vm/lima/cmd/limactl/main.go:26 +0x18

Additional context

I'm installing this package on Ubuntu via devbox. I'm really trying to get colima running. Colima uses lima with the docker template.

I don't see this issue with the colima/lima package on macos.

Notify maintainers

@r-ryantm @zowoq

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/9j1f45904jshhlsmb9ljqaxdkg86ajl2-nix-info
copying path '/nix/store/9j1f45904jshhlsmb9ljqaxdkg86ajl2-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 6.5.0-1023-aws, Ubuntu, 22.04.4 LTS (Jammy Jellyfish), nobuild`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/home/gwarner/.nix-defexpr/channels/nixpkgs`

Add a :+1: reaction to issues you find important.

gdw2vs commented 2 months ago

When I build the binaries on my host with go v1.22.0 (e.g. clone the repo, run make), the resulting binaries also produce the same stack trace.

But, when I build with go v1.23.0, the resulting binaries work.

Although I'm learning, I don't know how to tweak the lima derivation to always build with go > 1.23.x.

(I tried this approach after seeing this line in the lima github actions. I was looking for possible differences to how the official binary is build and how nix might be building it).

gdw2vs commented 2 months ago

Something's fishy. When I build lima with the unstable go v1.23.0 (e.g. nix-shell -p go_1_23) I still get the stack trace. When I build with the go provided by devbox global add go@1.23.0, it works. I would've expected these to be the same derivation. I have more learning to do.

It would be helpful if someone running on nixos proper can let me know whether limactl is working for them with the docker template.