NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.33k stars 13.57k forks source link

JetBrains GoLand: Delve Debugger Segfaults #331479

Open oxzi opened 1 month ago

oxzi commented 1 month ago

Describe the bug

The current unstable goland package cannot debug any code anymore as the shipped dlv segfaults. This issue seems to be new, as it just worked the other day.

Steps To Reproduce

$ readlink $(which goland)
/nix/store/q9aa6nlcryak3hkahbh9wxkchil1fdhm-goland-2024.1.4/bin/goland
$ goland --version
[0.004s][warning][cds] Archived non-system classes are disabled because the java.system.class.loader property is specified (value = "com.intellij.util.lang.PathClassLoader"). To use archived non-system classes, this property must not be set
CompileCommand: exclude com/intellij/openapi/vfs/impl/FilePartNodeRoot.trieDescend bool exclude = true
GoLand 2024.1.4
Build #GO-241.18034.61

Try to debug any Go code with GoLand. The debug console shows an error like:

/nix/store/kqf4gwhq1yrchvmvqjh4adc4y9hxp9xk-go-1.22.5/share/go/bin/go tool test2json -t /nix/store/q9aa6nlcryak3hkahbh9wxkchil1fdhm-goland-2024.1.4/goland/plugins/go-plugin/lib/dlv/linux/dlv --listen=127.0.0.1:37623 --headless=true --api-version=2 --check-go-version=false --only-same-user=false exec /home/__REDACTED__/.cache/JetBrains/GoLand2024.1/tmp/GoLand/___go_test___REDACTED__.test -- -test.v -test.paniconexit0
test2json: signal: segmentation fault (core dumped)

Debugger finished with the exit code 1

Manually executing the shipped dlv version segfaults as well:

$ /nix/store/q9aa6nlcryak3hkahbh9wxkchil1fdhm-goland-2024.1.4/goland/plugins/go-plugin/lib/dlv/linux/dlv
[1]    29435 segmentation fault (core dumped)

$ file /nix/store/q9aa6nlcryak3hkahbh9wxkchil1fdhm-goland-2024.1.4/goland/plugins/go-plugin/lib/dlv/linux/dlv
/nix/store/q9aa6nlcryak3hkahbh9wxkchil1fdhm-goland-2024.1.4/goland/plugins/go-plugin/lib/dlv/linux/dlv: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/0wydilnf1c9vznywsvxqnaing4wraaxp-glibc-2.39-52/lib/ld-linux-x86-64.so.2, Go BuildID=cIsFcvIxhwXrdMoTr6bE/f7trPgXyv_DRbTlRM12I/roa-LHcxPVXeiUlCNeoh/_TbvYk1j3VdgYmgYc4fA, stripped

Expected behavior

Maybe don't segfault :point_right: :point_left:

Additional context

As a workaround, I got the debugger working by explicitly using dlv from the delve package. To do so:

  1. In GoLand: TabTab > Edit Custom VM Options
  2. Put the path to dlv from the nixpkgs prefixed with -Ddlv.path= there, like:
    • -Ddlv.path=/nix/store/vr8wx2rqyag96bh8pslax497cc0bxsy4-delve-1.22.1/bin/dlv or
    • -Ddlv.path=/run/current-system/sw/bin/dlv
  3. Restart GoLand (really, otherwise the config will be ignored!)

Notify maintainers

@tymscar

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 6.10.2, NixOS, 24.05 (Uakari), 24.05.3407.12bf09802d77`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos-24.05, nixos-hardware, nixos-unstable"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

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

labi-le commented 3 weeks ago

this solution worked for me:

{ pkgs, ... }:

let
  golandCustomDelve = pkgs.jetbrains.goland.overrideAttrs (oldAttrs: {
    postFixup = (oldAttrs.postFixup or "") + ''
      rm -f $out/goland/plugins/go-plugin/lib/dlv/linux/dlv
      ln -s ${pkgs.delve}/bin/dlv $out/goland/plugins/go-plugin/lib/dlv/linux/dlv
    '';

  });
in
{
# ...
}