How to debug buildFHSUserEnv segment fault

i try to build [easy connect], but buildFHSUserEnv only give: segment fault.
i have no idea where i can see to debug it.

[larluo@nixos-larluo:~/my-repo/my-env]$ nix-build -E "with import <nixpkgs> {}; callPackage nixpkgs/pkgs/applications/networking/remote/easy-connect  {}"

[larluo@nixos-larluo:~/my-repo/my-env]$ result/bin/easy-connect 
Segmentation fault (core dumped)

[larluo@nixos-larluo:~/my-repo/my-env]$ cat /home/larluo/my-repo/my-env/nixpkgs/pkgs/applications/networking/remote/easy-connect/default.nix                                                       
{ stdenv, dpkg, fetchurl, buildFHSUserEnv, qt5                                                                                                                                                     
}:                                                                                                                                                                                                 
                                                                                                                                                                                                   
let                                                                                                                                                                                                
  easyConnectFiles = stdenv.mkDerivation {                                                                                                                                                         
    name = "easyConnectFiles" ;                                                                                                                                                                    
    src = fetchurl {                                                                                                                                                                               
      url = http://download.sangfor.com.cn/download/product/sslvpn/pkg/linux_01/EasyConnect_x64.deb ;                                                                                              
      sha256 = "46f3fb2da61404e5f028fb6bc4eb12737a5dd75e1cef8cc3b6d502aa40a5bf4b" ;                                                                                                                
    } ;                                                                                                                                                                                            
                                                                                                                                                                                                   
    unpackCmd = "dpkg -x $src ." ;                                                                                                                                                                 
    sourceRoot = "." ;                                                                                                                                                                             
                                                                                                                                                                                                   
    nativeBuildInputs = [ qt5.wrapQtAppsHook dpkg ] ;                                                                                                                                              
                                                                                                                                                                                                   
    installPhase = ''                                                                                                                                                                              
      mkdir $out                                                                                                                                                                                   
      cp -r * $out/                                                                                                                                                                                
      chmod +x $out/usr/share/sangfor/EasyConnect/EasyConnect                                                                                                                                      
    '' ;                                                                                                                                                                                           
  } ;                                                                                                                                                                                              
in 
  buildFHSUserEnv {                                                                                                                                                                                
    name = "easy-connect" ;                                                                                                                                                                        
                                                                                                                                                                                                   
    targetPkgs = pkgs: [
      easyConnectFiles
       
      pkgs.fontconfig
      pkgs.atk
      pkgs.glib
      pkgs.gtk2
      pkgs.pango
      pkgs.gdk_pixbuf

      pkgs.cairo
      pkgs.freetype
      pkgs.dbus
      pkgs.dbus-glib
       
      pkgs.xorg.libX11
      pkgs.xorg.libxcb
      pkgs.xorg.libXi
      pkgs.xorg.libXcursor

      pkgs.xorg.libXdamage
      pkgs.xorg.libXrandr
      pkgs.xorg.libXcomposite
      pkgs.xorg.libXext
      pkgs.xorg.libXfixes
      pkgs.xorg.libXrender
      pkgs.xorg.libXtst

      pkgs.nss
      pkgs.nspr
      pkgs.alsaLib
      pkgs.cups
      pkgs.expat
    ] ;

    runScript = ''${easyConnectFiles}/usr/share/sangfor/EasyConnect/EasyConnect '' ;
  }
                                                                                                                                                                                            

Interesting… buildFHSUserEnv is using a small c program named chrootenv (link) it’s probably it that seg-faults. Maybe open an issue quoting @yegortimoshenko who seems to be the maintainer…

For what it’s worth, I was also seeing segfaults when I run a given command in a buildFHSUserEnv.

Here’s the nix file creating the buildFHSUserEnv:

This runs the Haskell build tool stack.

I was never able to actually figure out what caused the segfaults.


In my case, I am pretty sure that this segfault is not being directly caused by chrootenv, but instead being caused by stack.

I tried changing the nix script above to just run bash, and then launch stack from bash, but that also caused the segfault.

I tried various commands like gdb and valgrind, but I couldn’t figure out where the segfault was coming from.