JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

Projucer segfaults

Open suhr opened this issue 6 years ago • 6 comments

How to reproduce:

% cd extras/Projucer/Builds/LinuxMakefile
% nix-shell -p xorg.libX11 xorg.libXinerama xorg.libXext freetype gnome3.gtk pkgconfig curl gnome3.webkitgtk
% make -j2 CONFIG=Release
% build/Projucer

Backtrace:

Thread 6 "VersionChecker" received signal SIGSEGV, Segmentation fault.

#0  0x000000000075b647 in juce::WebInputStream::WebInputStream(juce::URL const&, bool) ()
#1  0x00000000007731b5 in juce::URL::createInputStream(bool, bool (*)(void*, int, int), void*, juce::String, int, juce::StringPairArray*, int*, int, juce::String) const ()
#2  0x00000000004e6c40 in LatestVersionCheckerAndUpdater::queryUpdateServer() ()
#3  0x00000000004e72b5 in non-virtual thunk to LatestVersionCheckerAndUpdater::run() ()
#4  0x000000000075293e in juce::Thread::threadEntryPoint() ()
#5  0x0000000000752a89 in juce::threadEntryProc(void*) ()
#6  0x00007ffff28ceef7 in start_thread () from /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libpthread.so.0
#7  0x00007ffff22cd22f in clone () from /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libc.so.6

System: Linux nixos 4.19.78 #1-NixOS SMP x86_64 GNU/Linux

Tested on the latest develop branch.

suhr avatar Oct 21 '19 07:10 suhr

I can't reproduce this on Ubuntu 18.04, 19.04 or Debian. Is this only happening on NixOS? Does the prebuilt Projucer binary that comes with the download from https://shop.juce.com/get-juce/download also crash?

ed95 avatar Oct 21 '19 15:10 ed95

Yes, the prebuilt Projucer binary also crashes with the same backtrace.

By the way, since Nix package manager isolates artifacts, you can try to reproduce this issue while using some other linux distributive.

suhr avatar Oct 21 '19 17:10 suhr

Thanks, I've managed to reproduce the crash by running installing Nix on Ubuntu 19.04 and running the nix-shell command that you posted above. The line it's crashing on is in JUCE's cURL code and it's crashing because the program is unable to load libcurl. You can see here that we try to open a number of possible .so files for libcurl (the open() method just calls dlopen) but when running in nix-shell none of these are opened successfully. I'm not familiar with Nix but shouldn't it be possible to dlopen a lib when running in nix-shell?

ed95 avatar Oct 23 '19 11:10 ed95

When I add curl to LD_LIBRARY_PATH, Projucer does not crash. Instead it shows a window and hangs my system completely except for mouse cursor.

By the way, there's how do you get the path to the curl library (assuming it's in the nix store):

% nix repl '<nixpkgs>'
nix-repl> pkgs.curl.out.outPath
"<path to curl>"

The library is in <path to curl>/lib.

I'm not familiar with Nix but shouldn't it be possible to dlopen a lib when running in nix-shell?

Sure, but the problem is Nix stores everything in /nix/store/.... And since there's no curl in the binary's RUNPATH, it doesn't know where to find it.

This issue can be of course fixed with patchelf or some wrapping. But segfault is not the best way of error reporting.

suhr avatar Oct 23 '19 16:10 suhr

This monster of a derivation seems to work, though it definitely has extraneous dependencies.
stdenv.mkDerivation rec {
  name = "juce";
  version = "7.0.0";
  src = fetchurl {
    url = "https://github.com/juce-framework/JUCE/releases/download/${version}/juce-${version}-linux.zip";
    sha256 = "jjamj9Tu17ZTUpjHeilFeldThp/aAOE1gP6J3v7MbCg=";
  };
  unpackPhase = ''
    ${unzip}/bin/unzip $src
  '';
  dontBuild = true;
  installPhase = ''
    cp -r JUCE $out
    mkdir $out/bin
    mv $out/Projucer $out/bin
  '';
  buildInputs = [
    alsa-lib
    curl.out
    freetype
    libpsl
    gtk3
    ladspa-sdk
    libdatrie
    libjack2
    libselinux
    libsepol
    libthai
    libuuid
    mesa
    pcre
    pkg-config
    webkitgtk
    xorg.libX11
    xorg.libXcomposite
    xorg.libXcursor
    xorg.libXdmcp
    xorg.libXext
    xorg.libXinerama
    xorg.libXrandr
    xorg.libXrender
    xorg.libXScrnSaver.out
    libxkbcommon
    epoxy
    dbus
    at-spi2-core
    xorg.libXtst
    libsysprof-capture
    sqlite.dev
    gcc-unwrapped.lib
  ];
  fixupPhase = "${patchelf}/bin/patchelf --add-rpath " + (lib.concatStringsSep ":" (map (input: "${input}/lib") buildInputs)) + " --set-interpreter ${glibc}/lib/ld-linux-x86-64.so.2 $out/bin/Projucer";
}

I plan on doing some work with Juce on NixOS, so if things go well I'll update this with a link to an overlay flake.

This issue can be of course fixed with patchelf or some wrapping. But segfault is not the best way of error reporting.

I think this point still stands though.

mtoohey31 avatar Jun 28 '22 02:06 mtoohey31