Bug Description
Android Studio (android-studio-canary) debugging doesn't work, it internally uses LLDB for debugging (and ships binaries for it with itself). It embeds LLDB inside a closed-source wrapper present in PACKAGE_ROOT/bin/lldb/bin/LLDBFrontend.
On attempting to execute this binary during debugging, it runs into the following error:
/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/LLDBFrontend: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
Reproduction Steps
- Open any NDK project on Android Studio
- Use the native debugging functionality
- Check the LLDB tab in the Debugger
Additional Observations
- Android Studio uses an FSH environment (
environment will be omitted henceforth) as opposed to using patchelf
- Android Studio comes with an in-built terminal, this launches a shell which should be in the aforementioned FSH environment
-
- This can be confirmed by checking the relevant FSH directories
-
- Additionally, it was confirmed using this that
/lib, /usr/lib, /usr/lib32 and /usr/lib64 contained libncurses.so.5 (as defined by the derivation)
strace -f'ing Android Studio shows the linker not going through directories specified by the FSH $LD_LINKER_PATH (Full Trace)
...
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/libncurses.so.5", O_RDONLY|O_CLOEXEC <unfinished ...>
21308 <... openat resumed>) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/haswell/x86_64/libncurses.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/haswell/x86_64", 0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/haswell/libncurses.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/haswell", 0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/x86_64/libncurses.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/x86_64", 0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls/libncurses.so.5", O_RDONLY|O_CLOEXEC <unfinished ...>
21308 <... openat resumed>) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/tls", <unfinished ...>
21308 <... stat resumed>0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/haswell/x86_64/libncurses.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/haswell/x86_64", <unfinished ...>
21308 <... stat resumed>0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/haswell/libncurses.so.5", O_RDONLY|O_CLOEXEC <unfinished ...>
21308 <... openat resumed>) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/haswell", <unfinished ...>
21308 <... stat resumed>0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/x86_64/libncurses.so.5", O_RDONLY|O_CLOEXEC <unfinished ...>
21308 <... openat resumed>) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/x86_64", <unfinished ...>
21308 <... stat resumed>0x7ffce8d2ff40) = -1 ENOENT (No such file or directory)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64/libncurses.so.5", O_RDONLY|O_CLOEXEC <unfinished ...>
21308 <... openat resumed>) = -1 ENOENT (No such file or directory)
21308 stat("/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/../lib64", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
21308 openat(AT_FDCWD, "/nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libncurses.so.5", O_RDONLY|O_CLOEXEC <unfinished ...>
21308 <... openat resumed>) = -1 ENOENT (No such file or directory)
21308 writev(2, [{iov_base="/nix/store/lam2yvqbrjgyv5m2b8rpb"..., iov_len=112}, {iov_base=": ", iov_len=2}, {iov_base="error while loading shared libra"..., iov_len=36}, {iov_base=": ", iov_len=2}, {iov_base="libncurses.so.5", iov_len=15}, {iov_base=": ", iov_len=2}, {iov_base="cannot open shared object file", iov_len=30}, {iov_base=": ", iov_len=2}, {iov_base="No such file or directory", iov_len=25}, {iov_base="\n", iov_len=1}], 10 <unfinished ...>
21308 <... writev resumed>) = 227
...
- To further confirm that
LLDBFrontend is not in the FSH environment, lld was run inside and outside it
-
nixos% ldd /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/LLDBFrontend
linux-vdso.so.1 (0x00007ffd189d6000)
liblldb.so.11git => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/liblldb.so.11git (0x00007f1391167000)
libc++.so.1 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/libc++.so.1 (0x00007f1391083000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f1390f40000)
libgcc_s.so.1 => /nix/store/jpf7r0zvv7a8xlk6330g0qcnimwxqc7l-gcc-10.2.0-lib/lib/libgcc_s.so.1 (0x00007f1390f26000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1390f05000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f1390d44000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/9p681337dfwxskgsszggb5px5r7zs3g2-glibc-multi-2.32-25/lib/ld-linux-x86-64.so.2 (0x00007f139578b000)
libpython3.8.so.1.0 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libpython3.8.so.1.0 (0x00007f13907a5000)
libncurses.so.5 => /usr/lib/libncurses.so.5 (0x00007f139073f000)
libform.so.5 => /usr/lib/libform.so.5 (0x00007f139072b000)
libpanel.so.5 => /usr/lib/libpanel.so.5 (0x00007f1390725000)
[mark@nixos:~]$ ldd /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/LLDBFrontend
linux-vdso.so.1 (0x00007ffc2d995000)
liblldb.so.11git => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/liblldb.so.11git (0x00007eff4f44c000)
libc++.so.1 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/libc++.so.1 (0x00007eff4f368000)
libm.so.6 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libm.so.6 (0x00007eff4f225000)
libgcc_s.so.1 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libgcc_s.so.1 (0x00007eff4f20b000)
libpthread.so.0 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libpthread.so.0 (0x00007eff4f1ea000)
libc.so.6 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libc.so.6 (0x00007eff4f027000)
/lib64/ld-linux-x86-64.so.2 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib64/ld-linux-x86-64.so.2 (0x00007eff53a6e000)
libpython3.8.so.1.0 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libpython3.8.so.1.0 (0x00007eff4ea8a000)
libncurses.so.5 => not found
libtinfo.so.5 => not found
libform.so.5 => not found
libpanel.so.5 => not found
libxml2.so.2.9.10 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libxml2.so.2.9.10 (0x00007eff4e8e4000)
libedit.so.0 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libedit.so.0 (0x00007eff4e8a9000)
libz.so.1 => not found
librt.so.1 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/librt.so.1 (0x00007eff4e89e000)
libdl.so.2 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libdl.so.2 (0x00007eff4e897000)
libutil.so.1 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libutil.so.1 (0x00007eff4e892000)
libz.so.1 => not found
libncurses.so.5 => not found
libtinfo.so.5 => not found
- It can be safely concluded when combining this with the prior
strace -f that LLDBFrontend is running outside of FSH
# libm.so.6
libm.so.6 => /usr/lib/libm.so.6 (0x00007f1390f40000)
libm.so.6 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libm.so.6 (0x00007eff4f225000)
21308 openat(AT_FDCWD, "/nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
# libgcc_s.so.1
libgcc_s.so.1 => /nix/store/jpf7r0zvv7a8xlk6330g0qcnimwxqc7l-gcc-10.2.0-lib/lib/libgcc_s.so.1 (0x00007f1390f26000)
libgcc_s.so.1 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libgcc_s.so.1 (0x00007eff4f20b000)
21308 openat(AT_FDCWD, "/nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
# libpthread.so.0
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1390f05000)
libpthread.so.0 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libpthread.so.0 (0x00007eff4f1ea000)
21308 openat(AT_FDCWD, "/nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
# libc.so.6
libc.so.6 => /usr/lib/libc.so.6 (0x00007f1390d44000)
libc.so.6 => /nix/store/gafigwfaimlziam6qhw1m8dz4h952g1n-glibc-2.32-35/lib/libc.so.6 (0x00007eff4f027000)
21308 openat(AT_FDCWD, "/nix/store/m0xa5bz7vw7p43wi0jppvvi3c9vgqvp7-glibc-2.32-25/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
# libpython.3.8.so.1.0
libpython3.8.so.1.0 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libpython3.8.so.1.0 (0x00007f13907a5000)
libpython3.8.so.1.0 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libpython3.8.so.1.0 (0x00007eff4ea8a000)
21308 openat(AT_FDCWD, "/nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/lib64/libpython3.8.so.1.0", O_RDONLY|O_CLOEXEC) = 3
# libncurses.so.5
libncurses.so.5 => /usr/lib/libncurses.so.5 (0x00007f139073f000)
libncurses.so.5 => not found
21308 openat(AT_FDCWD, "{All Outside FSH $LD_LIBRARY_PATH Entries}/libncurses.so.5", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
LLDBFrontend was invoked from inside FSH (Through Android Studio's Terminal), this resulted in a successful invocation
nixos% /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/LLDBFrontend
Usage: <portnum> | <--version>
Potential Solutions
- FSH being fixed assuming this is a bug and not intended behavior, inconsistent behavior between
zsh and LLDBFrontend point to this. As far as I can tell, bubblewrap is at fault in that case.
patchelf the LLDBFrontend executable to use the correct libraries, I'm not familiar enough with patchelf nor modifying Nix derivations to do this.
Notify maintainers
@meutraa
Metadata
- system:
"x86_64-linux"
- host os:
Linux 5.10.12, NixOS, 21.03pre267812.7cbec40a095 (Okapi)
- multi-user?:
yes
- sandbox:
yes
- version:
nix-env (Nix) 2.3.10
- channels(mark):
"home-manager, nixos-21.03pre265130.f217c0ea7c1, nixpkgs-21.03pre265593.fcef64cc398"
- channels(root):
"nixos-21.03pre267812.7cbec40a095, nixpkgs-21.03pre268025.2c58a9dac0b"
- nixpkgs:
/home/mark/.nix-defexpr/channels/nixpkgs
Maintainer information:
attribute:
- androidStudioPackages.canary
module:
Bug Description
Android Studio (android-studio-canary) debugging doesn't work, it internally uses LLDB for debugging (and ships binaries for it with itself). It embeds LLDB inside a closed-source wrapper present in
PACKAGE_ROOT/bin/lldb/bin/LLDBFrontend.On attempting to execute this binary during debugging, it runs into the following error:
Reproduction Steps
Additional Observations
environmentwill be omitted henceforth) as opposed to usingpatchelf/lib,/usr/lib,/usr/lib32and/usr/lib64containedlibncurses.so.5(as defined by the derivation)strace -f'ing Android Studio shows the linker not going through directories specified by the FSH$LD_LINKER_PATH(Full Trace)LLDBFrontendis not in the FSH environment,lldwas run inside and outside itnixos% ldd /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/LLDBFrontend linux-vdso.so.1 (0x00007ffd189d6000) liblldb.so.11git => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/liblldb.so.11git (0x00007f1391167000) libc++.so.1 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/libc++.so.1 (0x00007f1391083000) libm.so.6 => /usr/lib/libm.so.6 (0x00007f1390f40000) libgcc_s.so.1 => /nix/store/jpf7r0zvv7a8xlk6330g0qcnimwxqc7l-gcc-10.2.0-lib/lib/libgcc_s.so.1 (0x00007f1390f26000) libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f1390f05000) libc.so.6 => /usr/lib/libc.so.6 (0x00007f1390d44000) /lib64/ld-linux-x86-64.so.2 => /nix/store/9p681337dfwxskgsszggb5px5r7zs3g2-glibc-multi-2.32-25/lib/ld-linux-x86-64.so.2 (0x00007f139578b000) libpython3.8.so.1.0 => /nix/store/lam2yvqbrjgyv5m2b8rpb4vrcv0h4ns4-android-studio-canary-2020.3.1.4-unwrapped/bin/lldb/bin/../lib64/../lib64/libpython3.8.so.1.0 (0x00007f13907a5000) libncurses.so.5 => /usr/lib/libncurses.so.5 (0x00007f139073f000) libform.so.5 => /usr/lib/libform.so.5 (0x00007f139072b000) libpanel.so.5 => /usr/lib/libpanel.so.5 (0x00007f1390725000)strace -fthatLLDBFrontendis running outside of FSHLLDBFrontendwas invoked from inside FSH (Through Android Studio's Terminal), this resulted in a successful invocationPotential Solutions
zshandLLDBFrontendpoint to this. As far as I can tell, bubblewrap is at fault in that case.patchelftheLLDBFrontendexecutable to use the correct libraries, I'm not familiar enough withpatchelfnor modifying Nix derivations to do this.Notify maintainers
@meutraa
Metadata
"x86_64-linux"Linux 5.10.12, NixOS, 21.03pre267812.7cbec40a095 (Okapi)yesyesnix-env (Nix) 2.3.10"home-manager, nixos-21.03pre265130.f217c0ea7c1, nixpkgs-21.03pre265593.fcef64cc398""nixos-21.03pre267812.7cbec40a095, nixpkgs-21.03pre268025.2c58a9dac0b"/home/mark/.nix-defexpr/channels/nixpkgsMaintainer information: