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

Memory Leaks in Termux #1804

Open
nitardus opened this issue May 17, 2024 · 7 comments
Open

Memory Leaks in Termux #1804

nitardus opened this issue May 17, 2024 · 7 comments

Comments

@nitardus
Copy link

nitardus commented May 17, 2024

After installing Moar, npq and rakudo as shown here, termux crashed when I tried to install zef. It finally succeded installing zef with --/test, but it now crashes when I try to install anything: rakudo-gdb-m reveals that while zef searches for packages, there is MASSIVE forking / threading going on in the background, until it runs out of memory at ~ 3 GiB memory usage. I recompiled moar with all sort of compiler options, and after using -asan, compilation of rakudo failed as follows:

==13894==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5120 byte(s) in 20 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7d7cd8 in MVM_bigint_radix /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:1630:16
    #3 0xb91c4f5b4a84 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3336:40
    #4 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 4864 byte(s) in 19 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7d17b4 in MVM_bigint_pow /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:650:24
    #3 0xb91c4f5ab914 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3267:40
    #4 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 2560 byte(s) in 10 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7cb258 in MVM_bigint_sub /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:393:1
    #3 0xb91c4f5b63c4 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3155:40
    #4 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 2304 byte(s) in 9 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7c9450 in MVM_bigint_neg /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:387:1
    #3 0xb91c4f5b2200 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3177:40
    #4 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 1536 byte(s) in 6 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7d1fe4 in MVM_bigint_shl /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:691:20
    #3 0xb91c4f5aa108 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3255:40
    #4 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 768 byte(s) in 3 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f8389a8 in mp_init_i64 /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init_i64.c:6:1
    #3 0xb91c4f672d04 in MVM_p6bigint_store_as_mp_int /data/data/com.termux/files/home/src/MoarVM/src/6model/reprs/P6bigint.c:96:16
    #4 0xb91c4f5baa88 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:6354:25
    #5 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #6 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #7 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 768 byte(s) in 3 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f54a728 in MVM_tc_create /data/data/com.termux/files/home/src/MoarVM/src/core/threadcontext.c:44:20
    #3 0xb91c4f816de8 in MVM_vm_create_instance /data/data/com.termux/files/home/src/MoarVM/src/moar.c:122:29
    #4 0xb91c4f540584 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:280:18
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 768 byte(s) in 3 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f54a728 in MVM_tc_create /data/data/com.termux/files/home/src/MoarVM/src/core/threadcontext.c:44:20
    #3 0xb91c4f5a18b4 in MVM_thread_new /data/data/com.termux/files/home/src/MoarVM/src/core/threads.c:31:5
    #4 0xb91c4f74836c in MVM_spesh_worker_start /data/data/com.termux/files/home/src/MoarVM/src/spesh/worker.c:281:38
    #5 0xb91c4f818180 in MVM_vm_create_instance /data/data/com.termux/files/home/src/MoarVM/src/moar.c:444:5
    #6 0xb91c4f540584 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:280:18
    #7 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #8 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 768 byte(s) in 3 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7ca27c in MVM_bigint_add /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:392:1
    #3 0xb91c4f5b7f68 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3150:40
    #4 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #5 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #6 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f7d3e9c in MVM_bigint_from_str /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:834:16
    #3 0xb91c4f7d47bc in MVM_coerce_sI /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:898:5
    #4 0xb91c4f5b7980 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3318:40
    #5 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #6 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #7 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f8389a8 in mp_init_i64 /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init_i64.c:6:1
    #3 0xb91c4f7c9140 in store_int64_result /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:78:20
    #4 0xb91c4f7cc510 in MVM_bigint_mul /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:394:1
    #5 0xb91c4f5b7880 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3160:40
    #6 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #7 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #8 0xb91c4f540024 in _start_main crtbegin.c

Direct leak of 256 byte(s) in 1 object(s) allocated from:
    #0 0xc56aecf21f14 in calloc out/lib/compiler-rt-aarch64/out/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:77:3
    #1 0xb91c4f838918 in mp_init /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init.c:10:25
    #2 0xb91c4f838b60 in mp_init_u32 /data/data/com.termux/files/home/src/MoarVM/3rdparty/libtommath/bn_mp_init_u32.c:6:1
    #3 0xb91c4f7d8100 in MVM_bigint_radix /data/data/com.termux/files/home/src/MoarVM/src/math/bigintops.c:1702:17
    #4 0xb91c4f5b4a84 in MVM_interp_run /data/data/com.termux/files/home/src/MoarVM/src/core/interp.c:3336:40
    #5 0xb91c4f5406c4 in main /data/data/com.termux/files/home/src/MoarVM/src/main.c:307:10
    #6 0xc56ae905f068 in __libc_init (/apex/com.android.runtime/lib64/bionic/libc.so+0x5c068) (BuildId: 19a02d177e7ca67cb275d7ae9857394c)
    #7 0xb91c4f540024 in _start_main crtbegin.c

SUMMARY: AddressSanitizer: 20224 byte(s) leaked in 79 allocation(s).
make: *** [Makefile:1361: blib/CORE.c.setting.moarvm] Aborted

Any ideas what to do? As I develop mainly on Android, it would be really nice if I could get raku working here...

MasterDuke17 added a commit to MasterDuke17/MoarVM that referenced this issue May 18, 2024
In a bunch of error cases of bigint ops we weren't always cleaning up
all the variables. These were noticed when investigating
MoarVM#1804, but I don't think they are
the actual cause.
@MasterDuke17
Copy link
Contributor

I believe the leaks reported by asan aren't "real". MoarVM does not cleanup all it's memory when exiting unless passed the --full-cleanup option (which can be given on the NQP and/or Rakudo command line and they'll propagate it). For example, if you build MoarVM with --asan, even raku -e '' reports a leak, but not raku --full-cleanup -e ''. So I think what happened here is that the rakudo build died, and the leaks reported are just stuff that wasn't garbage collected yet. I did notice some missing cleanups which I PRed in #1805, but those are all for extremely-unlikely-to-happen error cases.

How much ram do you have? zef might just use quite a bit, especially if it's the first time it's run and it has to precompile a bunch of stuff, but @ugexe would be the person to ask.

@niner
Copy link
Contributor

niner commented May 18, 2024

Zef installs things in parallel for the speedz, but that may not work well if you're quite memory restricted. However, the behavior is configurable:

--[phase]-degree=[int] Number of simultaneous distributions/jobs to process for the corresponding phase ( phase : fetch, test )

I suggest re-trying with --test-degree=1

lizmat pushed a commit that referenced this issue May 18, 2024
In a bunch of error cases of bigint ops we weren't always cleaning up
all the variables. These were noticed when investigating
#1804, but I don't think they are
the actual cause.
@ugexe
Copy link
Contributor

ugexe commented May 18, 2024

I suggest re-trying with --test-degree=1

The default test degree for zef is 1. The default for fetch degree is 5, although that is unlikely to be related to the issue here since --/test seems to avoid it.

reveals that while zef searches for packages, there is MASSIVE forking / threading going on in the background

zef does search in parallel, although in a per-ecosystem way, i.e. zef searching by default in the worst case would search 2 ecosystems at the same time. However that doesn't seem connected to "MASSIVE forking / threading". It might be worth running zef with --debug and see if you can note what the output is when the spike in threading occurs. I'd also be interested if zef installs other distributions OK when using --/test (as it is not clear to me if you already tried that other than to install zef itself).

Another thing zef spawns threads for is to run each phase (e.g. test), specifically for --[phase]-timeout=... functionality. Here is an example of the timeout pattern used. Note that if trying to golf this problem using that example as inspiration, make sure the code being run spawns processes, as that is a potentially complicating factor (I know this pattern is not ideal in seemingly unrelated ways though, like await Promise.anyof: $todo, $time-up; not having a way to kill the $todo thread when $time-up is reached).

Speaking of spawning processes, the primary way zef spawns threads is indirectly via spawning processes. For example the default for fetching basically does run 'curl', ..., and for testing run 'raku', $path-to-staging-repo, $test-file. Specifically for testing, see this code where we spawn the process to test a given distribution.

if it's the first time it's run and it has to precompile a bunch of stuff

Precompilation would occur during the staging phase, which happens immediately before testing. Precompilation does spawn processes, but by the time testing occurs that would already be finished i.e. the staging repository has all the precompiled files before (and regardless of if) we start to run any tests. That doesn't mean re-precompilation isn't occuring for some unknown reason, but theoretically it shouldn't be. To your point the first time zef is run to install itself it would have to precompile a bunch of stuff (itself) before it is able to stage (and thus re-precompile) itself to be installed.

@nitardus
Copy link
Author

nitardus commented May 18, 2024

Thank you all for your answers! I'm running Termux on a Google Pixel 6A with 6GB of RAM.

After installing zef sucessfully with --/test, I succeded to install with it locally two dozen Modules after downloading the source manually. Building and installing seems therefore no problem. However if I try to install some module directly, it only prints "Searching for module" (and at the most "Searching for missing dependency", with and without --debug). After that, it fails either with "Killed" or "Segmentation fault" after ca. 10 seconds or with Termux crashing after ca. 30 seconds. But there is an exception: Modules that come without any depenencies (packages with no missing dependencies keep failing) can be installed normally with no issues.

I also ran zef test . --debug in the zef repo: This was the output:

===> Testing: zef:ver<0.22.0>:auth<github:ugexe>:api<0>
[zef] Testing with plugin: Zef::Service::Shell::Test
[zef] 1..2
[zef] # Subtest: Core
[zef]     ok 1 - Zef module can be use-d ok
[zef]     ok 2 - Zef::Build module can be use-d ok
[zef]     ok 3 - Zef::Config module can be use-d ok
[zef]     ok 4 - Zef::Extract module can be use-d ok
[zef]     ok 5 - Zef::Identity module can be use-d ok
[zef]     ok 6 - Zef::Test module can be use-d ok
[zef]     ok 7 - Zef::Install module can be use-d ok
[zef]     ok 8 - Zef::Fetch module can be use-d ok
[zef]     ok 9 - Zef::Client module can be use-d ok
[zef]     ok 10 - Zef::Repository module can be use-d ok
[zef]     ok 11 - Zef::Repository::LocalCache module can be use-d ok
[zef]     ok 12 - Zef::Repository::Ecosystems module can be use-d ok
[zef]     ok 13 - Zef::Distribution module can be use-d ok
[zef]     ok 14 - Zef::Distribution::DependencySpecification module can be use-d ok
[zef]     ok 15 - Zef::Distribution::Local module can be use-d ok
[zef]     ok 16 - Zef::Utils::FileSystem module can be use-d ok
[zef]     ok 17 - Zef::Utils::SystemQuery module can be use-d ok
[zef]     ok 18 - Zef::Utils::URI module can be use-d ok
[zef]     1..18
[zef] ok 1 - Core
[zef] # Subtest: Plugins
[zef]     ok 1 - Zef::Service::FetchPath module can be use-d ok
[zef]     ok 2 - Zef::Service::TAP module can be use-d ok
[zef]     ok 3 - Zef::Service::InstallRakuDistribution module can be use-d ok
[zef]     ok 4 - Zef::Service::FileReporter module can be use-d ok
[zef]     ok 5 - Zef::Service::Shell::DistributionBuilder module can be use-d ok
[zef]     ok 6 - Zef::Service::Shell::LegacyBuild module can be use-d ok
[zef]     ok 7 - Zef::Service::Shell::Test module can be use-d ok
[zef]     ok 8 - Zef::Service::Shell::unzip module can be use-d ok
[zef]     ok 9 - Zef::Service::Shell::tar module can be use-d ok
[zef]     ok 10 - Zef::Service::Shell::curl module can be use-d ok
[zef]     ok 11 - Zef::Service::Shell::git module can be use-d ok
[zef]     ok 12 - Zef::Service::Shell::wget module can be use-d ok
[zef]     1..12
[zef] ok 2 - Plugins
[zef] 1..1
[zef] # Subtest: Zef::Build.build
[zef]     # Subtest: Two builders, first does not match/handle uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 1 - Two builders, first does not match/handle uri
[zef]     # Subtest: Two builders, first not capable of handling given uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - Two builders, first not capable of handling given uri
[zef]     # Subtest: Two builders, first fails
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two builders, first fails
[zef]     # Subtest: Two builders, first times out
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two builders, first times out
[zef]     1..4
[zef] ok 1 - Zef::Build.build
[zef] 1..35
[zef] ok 1 -
[zef] ok 2 -
[zef] ok 3 -
[zef] ok 4 -
[zef] ok 5 -
[zef] ok 6 -
[zef] ok 7 -
[zef] ok 8 -
[zef] ok 9 -
[zef] ok 10 -
[zef] ok 11 -
[zef] ok 12 -
[zef] ok 13 -
[zef] ok 14 -
[zef] ok 15 -
[zef] ok 16 -
[zef] ok 17 -
[zef] ok 18 -
[zef] ok 19 -
[zef] ok 20 -

After that, Termux crashed (again, memory usage was about 3GB)

Thank you all for your detailed and quick answers, your help is much appreciated!

@ugexe
Copy link
Contributor

ugexe commented May 18, 2024

@nitardus I would expect to see more newlines than what you've shown - for example [zef] should always be at the start of any line it appears in. Does what you've pasted here match the formatting of the output as you see it? An example of what I would expect the output to be formatted:

[zef]     ok 2 - Two builders, first not capable of handling given uri
[zef]     # Subtest: Two builders, first fails
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two builders, first fails
[zef]     # Subtest: Two builders, first times out
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two builders, first times out
[zef]     1..4
[zef] ok 1 - Zef::Build.build
[zef] ok
[zef] t/distribution-depends-parsing.rakutest ..
[zef] 1..35
[zef] ok 1 -
[zef] ok 2 -

@nitardus
Copy link
Author

nitardus commented May 19, 2024

Yes, it does, I made some simple mistakes in the formatting of my post yesterday when I tried to insert the copied output of the deceased termux session into the browser (these things are a bit cumbersome on the phone). I fixed this now. I had however added the last two subtest results manually, since I saw them on screen before termux blew up, but was not able to copy them to the clipboard in time (redirecting the test output to a file did fail due to buffering).

I tried it again today and surprisingly this time zef died with a simple error. Here is the log of the run:

===> Testing: zef:ver<0.22.0>:auth<github:ugexe>:api<0>

[zef] Testing with plugin: Zef::Service::Shell::Test
[zef] 1..2
[zef] # Subtest: Core
[zef]     ok 1 - Zef module can be use-d ok
[zef]     ok 2 - Zef::Build module can be use-d ok
[zef]     ok 3 - Zef::Config module can be use-d ok
[zef]     ok 4 - Zef::Extract module can be use-d ok
[zef]     ok 5 - Zef::Identity module can be use-d ok
[zef]     ok 6 - Zef::Test module can be use-d ok
[zef]     ok 7 - Zef::Install module can be use-d ok
[zef]     ok 8 - Zef::Fetch module can be use-d ok
[zef]     ok 9 - Zef::Client module can be use-d ok
[zef]     ok 10 - Zef::Repository module can be use-d ok
[zef]     ok 11 - Zef::Repository::LocalCache module can be use-d ok
[zef]     ok 12 - Zef::Repository::Ecosystems module can be use-d ok
[zef]     ok 13 - Zef::Distribution module can be use-d ok
[zef]     ok 14 - Zef::Distribution::DependencySpecification module can be use-d ok
[zef]     ok 15 - Zef::Distribution::Local module can be use-d ok
[zef]     ok 16 - Zef::Utils::FileSystem module can be use-d ok
[zef]     ok 17 - Zef::Utils::SystemQuery module can be use-d ok
[zef]     ok 18 - Zef::Utils::URI module can be use-d ok
[zef]     1..18
[zef] ok 1 - Core
[zef] # Subtest: Plugins
[zef]     ok 1 - Zef::Service::FetchPath module can be use-d ok
[zef]     ok 2 - Zef::Service::TAP module can be use-d ok
[zef]     ok 3 - Zef::Service::InstallRakuDistribution module can be use-d ok
[zef]     ok 4 - Zef::Service::FileReporter module can be use-d ok
[zef]     ok 5 - Zef::Service::Shell::DistributionBuilder module can be use-d ok
[zef]     ok 6 - Zef::Service::Shell::LegacyBuild module can be use-d ok
[zef]     ok 7 - Zef::Service::Shell::Test module can be use-d ok
[zef]     ok 8 - Zef::Service::Shell::unzip module can be use-d ok
[zef]     ok 9 - Zef::Service::Shell::tar module can be use-d ok
[zef]     ok 10 - Zef::Service::Shell::curl module can be use-d ok
[zef]     ok 11 - Zef::Service::Shell::git module can be use-d ok
[zef]     ok 12 - Zef::Service::Shell::wget module can be use-d ok
[zef]     1..12
[zef] ok 2 - Plugins
[zef] 1..1
[zef] # Subtest: Zef::Build.build
[zef]     # Subtest: Two builders, first does not match/handle uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 1 - Two builders, first does not match/handle uri
[zef]     # Subtest: Two builders, first not capable of handling given uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - Two builders, first not capable of handling given uri
[zef]     # Subtest: Two builders, first fails
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two builders, first fails
[zef]     # Subtest: Two builders, first times out
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two builders, first times out
[zef]     1..4
[zef] ok 1 - Zef::Build.build
[zef] 1..35
[zef] ok 1 -
[zef] ok 2 -
[zef] ok 3 -
[zef] ok 4 -
[zef] ok 5 -
[zef] ok 6 -
[zef] ok 7 -
[zef] ok 8 -
[zef] ok 9 -
[zef] ok 10 -
[zef] ok 11 -
[zef] ok 12 -
[zef] ok 13 -
[zef] ok 14 -
[zef] ok 15 -
[zef] ok 16 -
[zef] ok 17 -
[zef] ok 18 -
[zef] ok 19 -
[zef] ok 20 -
[zef] 1..1
[zef] # Subtest: Zef::Extract.extract
[zef]     # Subtest: Two extracters, first does not match/handle uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 1 - Two extracters, first does not match/handle uri
[zef]     # Subtest: Two extracters, first not capable of handling given uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - Two extracters, first not capable of handling given uri
[zef]     # Subtest: Two extracters, first fails
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two extracters, first fails
[zef]     # Subtest: Two extracters, first times out
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two extracters, first times out
[zef]     1..4
[zef] ok 1 - Zef::Extract.extract
[zef] 1..1
[zef] # Subtest: Zef::Fetch.fetch
[zef]     # Subtest: Two fetchers, first does not match/handle uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 1 - Two fetchers, first does not match/handle uri
[zef]     # Subtest: Two fetchers, first not capable of handling given uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - Two fetchers, first not capable of handling given uri
[zef]     # Subtest: Two fetchers, first fails
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two fetchers, first fails
[zef]     # Subtest: Two fetchers, first times out
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two fetchers, first times out
[zef]     1..4
[zef] ok 1 - Zef::Fetch.fetch
[zef] 1..6
[zef] # Subtest: Require spec - exact
[zef]     ok 1 -
[zef]     ok 2 -
[zef]     ok 3 -
[zef]     ok 4 -
[zef]     ok 5 -
[zef]     ok 6 -
[zef]     1..6
[zef] ok 1 - Require spec - exact
[zef] # Subtest: Require spec - range *
[zef]     ok 1 -
[zef]     ok 2 -
[zef]     ok 3 -
[zef]     1..3
[zef] ok 2 - Require spec - range *
[zef] # Subtest: Require spec - range +
[zef]     ok 1 -
[zef]     ok 2 -
[zef]     ok 3 -
[zef]     ok 4 -
[zef]     ok 5 -
[zef]     ok 6 -
[zef]     1..6
[zef] ok 3 - Require spec - range +
[zef] # Subtest: str2identity
[zef]     ok 1 -
[zef]     # Subtest: exact
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - exact
[zef]     # Subtest: not exact
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - not exact
[zef]     # Subtest: root namespace
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - root namespace
[zef]     1..4
[zef] ok 4 - str2identity
[zef] # Subtest: identity2hash
[zef]     ok 1 -
[zef]     ok 2 -
[zef]     ok 3 -
[zef]     ok 4 -
[zef]     1..4
[zef] ok 5 - identity2hash
[zef] # Subtest: hash2identity
[zef]     ok 1 -
[zef]     ok 2 -
[zef]     1..2
[zef] ok 6 - hash2identity
[zef] 1..1
[zef] # Subtest: Zef::Install.install
[zef]     # Subtest: Two installers, first does not match/handle uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 1 - Two installers, first does not match/handle uri
[zef]     # Subtest: Two installers, first not capable of handling given uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - Two installers, first not capable of handling given uri
[zef]     # Subtest: Two installers, first fails and second is not tried
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two installers, first fails and second is not tried
[zef]     # Subtest: Two installers, first times out and second is not tried
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two installers, first times out and second is not tried
[zef]     1..4
[zef] ok 1 - Zef::Install.install
[zef] 1..1
[zef] # Subtest: Zef::Repository.candidates
[zef]     # Subtest: api + version sorting
[zef]         ok 1 - Results are grouped by Candidate.as
[zef]         ok 2 - Results return sorted from highest api/ver to lowest
[zef] 1..1
[zef] # Subtest: Zef::Test.test
[zef]     # Subtest: Two testers, first does not match/handle uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 1 - Two testers, first does not match/handle uri
[zef]     # Subtest: Two testers, first not capable of handling given uri
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 2 - Two testers, first not capable of handling given uri
[zef]     # Subtest: Two testers, first fails and second is not tried
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 3 - Two testers, first fails and second is not tried
[zef]     # Subtest: Two testers, first times out and second is not tried
[zef]         ok 1 -
[zef]         1..1
[zef]     ok 4 - Two testers, first times out and second is not tried
[zef]     1..4
[zef] ok 1 - Zef::Test.test
[zef] 1..4
[zef] # Subtest: list-paths and delete-paths :d :f :r (rm -rf)
[zef]     ok 1 - Folder available to delete
[zef]     ok 2 -
[zef]     ok 3 - file was found in list-paths
[zef]     ok 4 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/1
[zef]     ok 5 - file was found in list-paths
[zef]     ok 6 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/1/deleteme-subfolder
[zef]     ok 7 - file was found in list-paths
[zef]     ok 8 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/1/base-delete.me
[zef]     ok 9 - file was found in list-paths
[zef]     ok 10 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/1/deleteme-subfolder/sub-delete.me
[zef]     1..10
[zef] ok 1 - list-paths and delete-paths :d :f :r (rm -rf)
[zef] # Subtest: list-paths and delete-paths :d :f (no recursion)
[zef]     ok 1 - Folder available to delete
[zef]     ok 2 -
[zef]     ok 3 - File was found in list-paths
[zef]     ok 4 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/2/base-delete.me
[zef]     ok 5 - Did not delete sub-file or delete non-empty directory
[zef]     1..5
[zef] ok 2 - list-paths and delete-paths :d :f (no recursion)
[zef] # Subtest: list-paths and delete-paths :d :r
[zef]     ok 1 - Folder available to delete
[zef]     ok 2 -
[zef]     ok 3 - File was found in list-paths
[zef]     ok 4 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/3/empty-subfolder
[zef]     ok 5 - Did not delete sub-file or delete non-empty directory
[zef]     1..5
[zef] ok 3 - list-paths and delete-paths :d :r
[zef] # Subtest: list-paths and delete-paths :f :r
[zef]     ok 1 - Folder available to delete
[zef]     ok 2 -
[zef]     ok 3 - File was found in list-paths
[zef]     ok 4 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/4/base-delete.me
[zef]     ok 5 - Did not delete sub-file or delete non-empty directory
[zef]     ok 6 - File was found in list-paths
[zef]     ok 7 - Deleted: /data/data/com.termux/files/usr/tmp/1716094371/4/deleteme-subfolder/sub-delete.me
[zef]     ok 8 - Did not delete sub-file or delete non-empty directory
[zef]     1..8
[zef] ok 4 - list-paths and delete-paths :f :r
===> Testing [FAIL]: zef:ver<0.22.0>:auth<github:ugexe>:api<0>

I ran it immediately afterwards about 20 times: Nearly always it crashed at the same spot as yesterday (that is, after subtest 18 finished, it took around 30 seconds for subtest 19 and 20 to finish, and then after some other 10 seconds it crashes).
Three times it cleared this phase really quickly but only once I got the same normal failure as described above. The two other times it hanged and caused termux to crash after these tests:

[zef] # Subtest: Zef::Repository.candidates
[zef]     # Subtest: api + version sorting
[zef]         ok 1 - Results are grouped by Candidate.as
[zef]         ok 2 - Results return sorted from highest api/ver to lowest

@ugexe
Copy link
Contributor

ugexe commented May 20, 2024

Hmm, that specific test can be seen here. It is not particularly heavy weight, and even uses mocked repository objects that only have a few names available to search. The candidates function does the heavy lifting for that test.

I'm not sure how to debug further beyond adding debug print statements at various points in that function to hopefully pinpoint the specific lines causing this. For example: add use Telemetry; to Zef::Repository add say T<max-rss>; at various points in the candidates method, then run raku -I. t/repository.rakutest or raku -I. bin/zef install SomeModule (where -I. points at a locally cloned zef repo with the debug print statements added).

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