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 66 forks source link

emacs path.c assertion "length2 > 0" failed #12

Closed codygman closed 4 years ago

codygman commented 4 years ago

Warning: no reproduction yet

[ ] - bisect packages to identify package triggering paths.c [ ] - create minimal repro with emacs -Q

Using my quite large emacs config i get the following error.

./path/path.c:547: Comparison compare_paths2(const char *, size_t, const char *, size_t): assertion "length2 > 0" failed
  proot warning: signal 6 received from process 5597

Putting this here in this pre repro state in case others want to see state of emacs support or someone recognizes that error.

I'll debug this further as time allows.

Atemu commented 4 years ago

I encounter the same issue in my fairly vanilla Spacemacs config but only when I try to C-x C-f/SPC f f (handled by HELM in my case).

Gerschtli commented 4 years ago

Could you post your minimal config and exact instructions on how to reproduce this error?

Atemu commented 4 years ago

.spacemacs from atemu/dotfiles@ac526f496eccda63ebacacf77fc356651756ed31

.emacs.d is syl20bnr/spacemacs@d95d41f55ba074128b3ed8f0eedcdc3c31b52e42

  1. Run emacs
  2. Let it install all the packages (I needed to set the elpa timeout to something higher than 5s, YMMV)
  3. C-x C-f
jakalx commented 4 years ago

I ran into the same issue. Using ivy instead of helm doesn't trigger this bug.

There seems to be a fix in https://github.com/0pq76r/proot/commit/7d7479c490de083729253f120a5e9a9c5bd47d0c but it's not yet upstream.

jakalx commented 4 years ago

I am finally able to reproduce it:

emacs -Q --batch --eval '(directory-files-and-attributes "/data/data/com.termux.nix/files/usr/bin" nil "\\`[^.]" t (quote string))'

Gerschtli commented 4 years ago

Nice, i can confirm to get the same error. But could you explain, what this does and what similar commands you tried that worked? I'm asking for so many details because I have neither used emacs nor came in touch with the nix expression of emacs and its dependencies.

jakalx commented 4 years ago

I basically opened an eshell within emacs and did an ls in the usr/bin directory and that crashed, other directories work just fine. Afterwards I stepped through the callstack and ended up in the function mentioned above. Said function is implemented in C which makes debugging much harder. Currently, I'm trying to extract a single C function that triggers the bug, based on this source: https://github.com/emacs-mirror/emacs/blob/c70a3a41630a39283f10f183cefb4643a6d424cc/src/dired.c#L166

jakalx commented 4 years ago

Just tried again, a simple ls -a in my $HOME from within eshell does also crash. That means, it's not specific to the directory but its contents somehow. Doing the same things using the real ls and not the emacs version, works in all cases.

jakalx commented 4 years ago

It seems to be the link to /nix, i.e. the .nix-profile. I tried the following steps:

emacs -Q
M-x eshell
mkdir tmp
cd tmp
ls
# ok
ln -s /nix .
ls
# bam
t184256 commented 4 years ago

Does it fail the same with other proot-rerouted locations like /tmp or /usr?

Should we incorporate the fix linked above in advance into our proot build?

jakalx commented 4 years ago

Funny, /tmp is ok, /etc /bin are not. That might be because /tmp doesn't contain links into proot bindings as the other directories do.

jakalx commented 4 years ago

Hi, how can I get a custom version of proot into my nix-on-droid installation? I'm still a noob regarding nix :(

Btw. the issue is reproducible on my laptop as well, but I didn't have time to figure out which syscall fails in proot. My goal is to have a unit test along with a fix for proot.

Is there an irc (or similar) channel for nix-on-droid?

t184256 commented 4 years ago

It's not a particularly simple process, as it can't be built on-device (refer to https://gist.github.com/t184256/c79d270498e8441d0f4e3c9be7acad18 if you want an overview of how the building happens and how to start with your own channels and bootstrap zipballs).

Meanwhile, you can try bootstrapping from https://nix-on-droid.unboiled.info/bootstrap-proot-fix (corresponds to proot-fix branch, where I've applied patch mentioned above to proot) and verify whether it fixes the issue.

As for a support chat, we don't have any, though maybe we should have one. Got any specific suggestions?

jakalx commented 4 years ago

The fix seems to work. I replaced my proot-static binary with the one from your package and emacs does not crash anymore.

t184256 commented 4 years ago

I've merged the fix (9b4fb44) into the master branch then.