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

Executables are not working under NixOS #2451

Open
corpix opened this issue Jan 16, 2019 · 4 comments
Open

Executables are not working under NixOS #2451

corpix opened this issue Jan 16, 2019 · 4 comments

Comments

@corpix
Copy link
Contributor

corpix commented Jan 16, 2019

Hello. Executable files built with raco exe ./app.rkt is not working under NixOS.

Example source code:

#lang racket/base
(displayln "hello")

Works with interpreter but built executable fails:

bash-4.4# racket ./hello.rkt
hello
bash-4.4# raco exe ./hello.rkt && ./hello
open-input-bytes: contract violation
  expected: bytes?
  given: #<eof>
  context...:
   embedded-load

Steps to reproduce:

Run a nix-shell on NixOS or with docker:

docker run --rm -it nixos/nix:latest /usr/bin/env nix-shell -p bashInteractive -p racket --run bash

Write sample program:

cat <<EOF > hello.rkt
#lang racket/base
(displayln "hello")
EOF

Run it and it will fail with "contract violation" error I have mentioned earlier:

raco exe ./hello.rkt && ./hello

Current workaround is to use --gui flag to build an executable.

@Mic92
Copy link

Mic92 commented Jan 20, 2019

There also seems to be a segmentation fault when running raco exe:

$ gdb --args sh raco exe src/nix-sysdig.rkt
(gdb) set follow-fork-mode child
(gdb) r
Starting program: /nix/store/00aqq7zm73ca5rck3k4yf4z339lxzy2w-bash-interactive-4.4-p23/bin/sh raco exe src/nix-sysdig.rkt
process 18464 is executing new program: /nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash
process 18464 is executing new program: /nix/store/vs6d2fjkl4kb3jb7rwibsd76k9v2n4xy-bash-4.4-p23/bin/bash
process 18464 is executing new program: /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/bin/.racket-wrapped
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/fivq0nbggp4y8mhy3ixprqd7qyn1hy2j-glibc-2.27/lib/libthread_db.so.1".
[New Thread 0x7ffff7e6b700 (LWP 18473)]

Thread 1 ".raco-wrapped" received signal SIGSEGV, Segmentation fault.
0x00007ffff784927c in scheme_gmp_tls_unload ()
   from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
(gdb) bt
#0  0x00007ffff784927c in scheme_gmp_tls_unload ()
   from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#1  0x00007ffff7a12433 in ?? () from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#2  0x00007ffff7a51c37 in ?? () from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#3  0x00007ffff7a53f11 in ?? () from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#4  0x00007ffff7a552fc in ?? () from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#5  0x00007ffff785348c in ?? () from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#6  0x00007ffff7853db0 in scheme_hash_set_w_key_wraps ()
   from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#7  0x00007ffff790e7e4 in ?? () from /nix/store/5qvx0zdd1ajb6mx4fc32caf8h39lpvc9-racket-7.1/lib/libracket3m-7.1.so
#8  0x00007ffff7e6331f in ?? ()
#9  0x00007fffedc7df58 in ?? ()
#10 0x00007ffff7e1e7f9 in ?? ()
#11 0x00007fffffff6fb0 in ?? ()
#12 0x00007ffff7fee748 in ?? ()
#13 0x00007fffffff6d98 in ?? ()

@mflatt
Copy link
Member

mflatt commented Jan 25, 2019

The signal in that trace is intended; it's a SIGSEGV that is handled to implement the GC"s writer barrier.

If you're seeing a crash that happens later, use handle SIGSEGV nostop noprint in gdb to get to the actual crash.

@Mic92
Copy link

Mic92 commented Jan 26, 2019

I also now suspect rather a packaging bug on the nixpkgs side,
because it works when I create packages with raco when it is build
from source: NixOS/nixpkgs#11698 (comment)

I suspect our shell wrapper around all the racket tools break the build
of the executable. The wrapper is needed in our case because the ffi
of racket needs LD_LIBRARY_PATH to find our libraries. Usually
we use the RPATH within the binary set to achieve this. I guess we need to
patch our build so racket to extend the same also for libraries that are not
explicitly linked.

@bennn
Copy link
Contributor

bennn commented Sep 11, 2019

Today I hit the same "contract violation" as @corpix

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

4 participants