xzfc / cached-nix-shell

Instant startup time for nix-shell
https://xzfc.github.io/cached-nix-shell/cached-nix-shell.1
The Unlicense
195 stars 16 forks source link

Regression: v0.1.2+ segfaults #16

Closed exFalso closed 4 years ago

exFalso commented 4 years ago

On latest master (as well as v0.1.2):

$ git rev-parse HEAD
9bd1649452280c20b4978bc0122208e2c6cd46f0
$ nix-build -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz
/nix/store/6aw0fiknqbks8jyy9226klajnb9m5sbq-cached-nix-shell-0.1.2
$ ./result/bin/cached-nix-shell
cached-nix-shell: updating cache
cached-nix-shell: nix-shell: signal: 11

Digging a bit further

$ gdb ./result/bin/cached-nix-shell
GNU gdb (GDB) 9.1
(...)
(No debugging symbols found in ./result/bin/cached-nix-shell)
(gdb) set follow-fork-mode child
(gdb) r
Starting program: /nix/store/6aw0fiknqbks8jyy9226klajnb9m5sbq-cached-nix-shell-0.1.2/bin/cached-nix-shell 
(...)
cached-nix-shell: updating cache
[Attaching after process 110059 fork to child process 110064]
[New inferior 2 (process 110064)]
[Detaching after fork from parent process 110059]
[Inferior 1 (process 110059) detached]
warning: File "/nix/store/6m2k8kx8h216jlx9dg3lp4m90bz05yck-glibc-2.30/lib/libthread_db-1.0.so" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
process 110064 is executing new program: /usr/bin/nix
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Thread 2.1 "nix-shell" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6427e40 (LWP 110064)]
0x0000000000000000 in ?? ()
(gdb) where
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff6fd13c0 in dlsym () from /nix/store/6m2k8kx8h216jlx9dg3lp4m90bz05yck-glibc-2.30/lib/libdl.so.2
#2  0x00007ffff7fc1c53 in __lxstat () from /nix/store/6aw0fiknqbks8jyy9226klajnb9m5sbq-cached-nix-shell-0.1.2/lib/trace-nix.so
#3  0x00007ffff753b91f in nix::pathExists(std::string const&) () from /usr/lib/libnixutil.so
#4  0x00007ffff797477f in nix::Settings::Settings() () from /usr/lib/libnixstore.so
#5  0x00007ffff797978d in ?? () from /usr/lib/libnixstore.so
#6  0x00007ffff7979862 in ?? () from /usr/lib/libnixstore.so
#7  0x00007ffff7fe20f2 in call_init.part () from /lib64/ld-linux-x86-64.so.2
#8  0x00007ffff7fe2201 in _dl_init () from /lib64/ld-linux-x86-64.so.2
#9  0x00007ffff7fd313a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#10 0x0000000000000005 in ?? ()
#11 0x00007fffffffeec4 in ?? ()
#12 0x00007fffffffeece in ?? ()
#13 0x00007fffffffeed5 in ?? ()
#14 0x00007fffffffeedb in ?? ()
#15 0x00007fffffffeee2 in ?? ()
#16 0x0000000000000000 in ?? ()
(gdb) 

So something's off with nix-trace.

This is on Arch Linux

$ uname -r
5.6.13-arch1-1
$ nix --version
nix (Nix) 2.3.4

Note that it works fine with v0.1.1

xzfc commented 4 years ago

I can reproduce it even on v0.1.1 when nix-shell is installed as an Arch package (in /usr/sbin/, not in /nix/store/…/bin/). It seems that libdl.so.2 from Nixpkgs (which is linked by trace-nix.so) doesn't play well with /usr/lib/libdl.so.2 (which is linked by nix-shell installed as an Arch package).


Could you check the latest master commit 290e3bdd3ff8cf166823536baa261bd494808827?

exFalso commented 4 years ago

That works, thanks!! Speedy!