nix-community / nix-on-droid

Nix-enabled environment for your Android device. [maintainers=@t184256,@Gerschtli]
https://nix-on-droid.unboiled.info
MIT License
1.23k stars 65 forks source link

Build of `home-manager` failed with Bus error #1

Closed ghost closed 5 years ago

ghost commented 5 years ago
Installing home-manager...
GC Warning: Couldn't read /proc/stat
GC Warning: Couldn't read /proc/stat
these derivations will be built:
/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv
GC Warning: Couldn't read /proc/stat
building '/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv'...
/nix/store/v262b100wnfjhyxjv5bk2zachznf3147-stdenv-linux/setup: line 1259: 24434 Bus error install -v -D -m755 /nix/store/3a2whifgkajbm618v1xx94j8llbm199a-home-manager $out/bin/home-manager
builder for '/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv' failed with exit code 135
error: build of '/nix/store/6n2w6f1g3rsdrlwl1pbfnxpp9qwrqazb-home-manager.drv' failed

ptrace on relevant line:

proot warning: ptrace request 'PTRACE_???' not supported yet
execve("/nix/store/cib5daqwbsbk6009r7pcpkd0snsf8brx-coreutils-8.30/bin/install", ["install", "/nix/store/3a2whifgkajbm618v1xx9"..., "/nix/store/szbfi2pknmdhr5xw5769k"...], 0x7fffffe540 /* 66 vars */) = 0
brk(NULL)                               = 0x561000
faccessat(AT_FDCWD, "/etc/ld-nix.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/tls", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}, 0) = 0
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/tls", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib", {st_mode=S_IFDIR|0555, st_size=4096, ...}, 0) = 0
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls/aarch64/librt.so.1", O
_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/tls", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/aarch64/librt.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/aarch64", 0x7fffffd5d0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0000\36\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=37464, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb7ffd000
mmap(NULL, 90464, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7fe6000
mprotect(0x7fb7fec000, 61440, PROT_NONE) = 0
mmap(0x7fb7ffb000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0x7fb7ffb000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\360\\\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=138776, ...}) = 0
mmap(NULL, 180680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7fb9000
mprotect(0x7fb7fd0000, 65536, PROT_NONE) = 0
mmap(0x7fb7fe0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7fb7fe0000
mmap(0x7fb7fe2000, 12744, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb7fe2000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\0\37\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=38688, ...}) = 0
mmap(NULL, 94320, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7fa1000
mprotect(0x7fb7fa8000, 61440, PROT_NONE) = 0
mmap(0x7fb7fb7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7fb7fb7000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libattr.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\240\27\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=23400, ...}) = 0
mmap(NULL, 81944, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7f8c000
mprotect(0x7fb7f90000, 61440, PROT_NONE) = 0
mmap(0x7fb7f9f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fb7f9f000
close(3)                                = 0
openat(AT_FDCWD, "/nix/store/lf7vr1lrzs8nnclhl85gl502sa17cb0b-acl-2.2.53/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/2ddlh6qy4qgzcdlh3lj44ynrbivr59fj-attr-2.4.48/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/m6bmjrz6zqp95qaj2jimyqyq65azis8v-glibc-2.27/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0\267\0\1\0\0\0\350\10\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0555, st_size=1590536, ...}) = 0
mmap(NULL, 1377136, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fb7e3b000
mprotect(0x7fb7f72000, 65536, PROT_NONE) = 0
mmap(0x7fb7f82000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x137000) = 0x7fb7f82000
mmap(0x7fb7f88000, 13168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb7f88000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb7e39000
mprotect(0x7fb7f82000, 16384, PROT_READ) = 0
mprotect(0x7fb7f9f000, 4096, PROT_READ) = 0
mprotect(0x7fb7fb7000, 4096, PROT_READ) = 0
mprotect(0x7fb7fe0000, 4096, PROT_READ) = 0
mprotect(0x7fb7ffb000, 4096, PROT_READ) = 0
mprotect(0x53c000, 45056, PROT_READ)    = 0
mprotect(0x3f0002c000, 4096, PROT_READ) = 0
set_tid_address(0x7fb7e39750)           = 13268
set_robust_list(0x7fb7e39760, 24)       = -1 ENOSYS (Function not implemented)
rt_sigaction(SIGRTMIN, {sa_handler=0x7fb7fbe750, sa_mask=[], sa_flags=SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7fb7fbe840, sa_mask=[], sa_flags=SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
prctl(PR_SET_NAME, "install")           = 0
prctl(PR_SET_KEEPCAPS, 549755807983)    = -1 EINVAL (Invalid argument)
brk(NULL)                               = 0x561000
brk(0x582000)                           = 0x582000
geteuid()                               = 10099
umask(000)                              = 022
newfstatat(AT_FDCWD, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", 0x7fffffe2f8, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/nix/store/3a2whifgkajbm618v1xx94j8llbm199a-home-manager", {st_mode=S_IFREG|0444, st_size=12499, ...}, 0) = 0
newfstatat(AT_FDCWD, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", 0x7fffffde48, AT_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/3a2whifgkajbm618v1xx94j8llbm199a-home-manager", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=12499, ...}) = 0
openat(AT_FDCWD, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb7e17000
read(3, "#!@bash@/bin/bash\n\n# Prepare to "..., 131072) = 12499
write(4, "#!@bash@/bin/bash\n\n# Prepare to "..., 12499) = 12499
read(3, "", 131072)                     = 0
fsetxattr(-95, "system.posix_acl_access", "\2\0\0\0\1\0\6\0\377\377\377\377\4\0\0\0\377\377\377\377 \0\0\0\377\377\377\377", 28, 0) = 4
fchmod(0, 0600)                         = 4
close(0)                                = 3
close(0)                                = 548545851392
munmap(NULL, 139264)                    = -1 ENETDOWN (Network is down)
fchmodat(-2, "/nix/store/szbfi2pknmdhr5xw5769kir8lwwdg8b2-home-manager/bin/home-manager", 0755 <unfinished ...>
--- SIGBUS {si_signo=SIGBUS, si_code=BUS_ADRALN, si_addr=0x7fb7e68008} ---
<... fchmodat resumed>)                 = ?
+++ killed by SIGBUS +++

Device: Xiaomi Redmi 4X, LineageOS 15.1-20181114-NIGHTLY-santoni

t184256 commented 5 years ago

Thank you very much for your really detailed report, but I'm afraid that doesn't make the problem more clear to me. My only supported device, Samsung SM-T719 with a similar CPU, has it working OK under LineageOS 16.

You're not the only one who reports this, if that makes things better =)

I suppose that installing prebuilt software works fine, but does building anything fail in a similar manner?

My list of erratic ideas that you could try:

  1. Checking if all install invocations fail like this.
  2. Adding -0 option to proot invocation in /data/data/com.termux.nix/usr/bin/login.
  3. Setting SELinux to permissive. Probably doesn't matter, but it should be a quick check.
  4. Adding -v 9 to proot invocation (will make things even more noisy).
  5. Replacing the install call with cp+chmod and calling it a day.
  6. Using qemu user-mode emulation to emulate aarch64 on your aarch64 for this install invocation and see if the problem goes away (a bit crazy).
  7. Trying unstable nixpkgs channel.
  8. Updating to my latest build (wipe the data and relaunch the app. probably won't change much, but installing home-manager is optional since 0f8ba89).

If you don't feel like going through that hassle, just update and try to proceed without installing home-manager and see if all installs fail like this one.

Note that you forgot -v -D -m755. Not like it would change anything though...

ghost commented 5 years ago

8. Updating to my latest build (wipe the data and relaunch the app. probably won't change much, but installing home-manager is optional since 0f8ba89).

Same error, but I can use it without home-manager :) Thank you!

  • Checking if all install invocations fail like this.

It looks like it is. I am getting same error while building clearsans from NUR But I can use install in console (for example touch test; install test test1 works fine there)

  • Adding -0 option to proot invocation in /data/data/com.termux.nix/usr/bin/login.

Same error

  • Setting SELinux to permissive. Probably doesn't matter, but it should be a quick check.

Phone in not rooted, so I can't do this for now

  • Trying unstable nixpkgs channel.

Same

Note that you forgot -v -D -m755. Not like it would change anything though...

Yeah, I did it on purpose to check ptrace output on "minimal" command

Thank you for the guidance, I think it is worth take another spin after https://github.com/NixOS/nixpkgs/pull/57339

t184256 commented 5 years ago

Oh, I have a plausible idea that my precompiled proot is to blame.

What you could do to test it:

  1. Try installing into and out of /nix and see if these fail.

  2. If that's the case, which I really hope it is, you may try recompiling proot in termux on your device. There is a sketch of a guide in the repo, feel free to ask questions.

ghost commented 5 years ago
  1. Try installing into and out of /nix and see if these fail.

Nope, it's OK :( (install test /nix/test1 and install /nix/test1 test2)

t184256 commented 5 years ago

Then I can't comprehend what on Earth makes these invocations failing inside nix builds any different. =/

t184256 commented 5 years ago

Due to bd7335a bringing all-new way to build proot, I kindly ask you to either

or, if you have a valuable setup that you don't want to backup and restore

While I still don't understand the nature of the bus error, the new binary is not tied to my tablet in any way and it works for me, so I really hope it will work on all devices.

ghost commented 5 years ago

Works like a charm :) Thank you very much!

t184256 commented 5 years ago

You're welcome. That makes two bus-error-begone reports, so 'yay' indeed!