Tor client on xiaomi 4A gigabit v2 hangs

It only hangs on v2 of this router model - here are some openwrt info:

Hostname	OpenWrt
Model	Xiaomi Mi Router 4A Gigabit Edition v2
Architecture	MediaTek MT7621 ver:1 eco:3
Target Platform	ramips/mt7621
Firmware Version	OpenWrt 23.05.4 r24012-d8dd03c46f / LuCI openwrt-23.05 branch git-24.086.45142-09d5a38
Kernel Version	5.15.162

sometimes tor just crashes:

Memory usage looks fine:

but if the bootstrap bypases 40% everything hangs and I can no longer access luci or ssh to read logs so I have no idea what's happening in the background.

Tue Aug 13 21:09:30 2024 daemon.notice Tor[3360]: Bootstrapped 0% (starting): Starting
Tue Aug 13 21:09:34 2024 daemon.notice Tor[3360]: The current consensus has no exit nodes. Tor can only build internal paths, such as paths to onion services.
Tue Aug 13 21:09:34 2024 daemon.notice Tor[3360]: Starting with guard context "default"
Tue Aug 13 21:09:35 2024 daemon.notice Tor[3360]: Bootstrapped 5% (conn): Connecting to a relay
Tue Aug 13 21:09:35 2024 daemon.warn Tor[3360]: Missing mapping for virtual address '[scrubbed]'. Refusing.
Tue Aug 13 21:09:35 2024 daemon.notice Tor[3360]: Bootstrapped 10% (conn_done): Connected to a relay
Tue Aug 13 21:09:35 2024 daemon.notice Tor[3360]: Bootstrapped 14% (handshake): Handshaking with a relay
Tue Aug 13 21:09:35 2024 daemon.warn Tor[3360]: Missing mapping for virtual address '[scrubbed]'. Refusing.
Tue Aug 13 21:09:35 2024 daemon.notice Tor[3360]: Bootstrapped 15% (handshake_done): Handshake with a relay done
Tue Aug 13 21:09:35 2024 daemon.notice Tor[3360]: Bootstrapped 45% (requesting_descriptors): Asking for relay descriptors
Tue Aug 13 21:09:36 2024 daemon.notice Tor[3360]: I learned some more directory information, but not enough to build a circuit: We need more microdescriptors: we have 0/7733, and can only build 0% of likely paths. (We have 0% of guards bw, 0% of midpoint bw, and 0% of end bw (no exits in consensus, using mid) = 0% of path bw.)
Tue Aug 13 21:09:36 2024 daemon.notice Tor[3360]: Bootstrapped 50% (loading_descriptors): Loading relay descriptors
Tue Aug 13 21:09:43 2024 daemon.notice Tor[3360]: The current consensus contains exit nodes. Tor can build exit and internal paths.

Any tips how to find the source of the problem?

Edit: even if I try with logread -f -e tor to follow the logs - they stop after the last message of 50% bootstrapping from tor. Everything crashes after that and I lose ssh connection

You are running out of memory, install zram-swap to somewhat compensate.

Indeed that made tor go further till 61% now.

Wed Aug 14 11:38:20 2024 daemon.notice Tor[3240]: I learned some more directory information, but not enough to build a circuit: We need more microdescriptors: we have 0/7694, and can only build 0% of likely paths. (We have 0% of guards bw, 0% of midpoint bw, and 0% of end bw (no exits in consensus, using mid) = 0% of path bw.)
Wed Aug 14 11:38:21 2024 daemon.notice Tor[3240]: Bootstrapped 50% (loading_descriptors): Loading relay descriptors
Wed Aug 14 11:38:43 2024 daemon.notice Tor[3240]: Bootstrapped 56% (loading_descriptors): Loading relay descriptors
Wed Aug 14 11:38:47 2024 daemon.notice Tor[3240]: Bootstrapped 61% (loading_descriptors): Loading relay descriptors

but still freezing after.

here my free; cat /proc/swaps

              total        used        free      shared  buff/cache   available
Mem:         120488       51592       49680         100       19216       34664
Swap:         59388           0       59388
Filename                                Type            Size            Used            Priority
/dev/zram0                              partition       59388           0               100

Is there anyway I can increase that 50mb to more? What should I set it to?

Edit: I did mange to increase it to 85mb but still same issue. Now hangs at 62% :slight_smile:

I tried to minimize the firmware size, and ram but still same issue.

"Used 0" means memory is not the problem