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

TorService in a separate process (revisited) #154

Open
syphyr opened this issue Jan 3, 2025 · 3 comments
Open

TorService in a separate process (revisited) #154

syphyr opened this issue Jan 3, 2025 · 3 comments
Assignees

Comments

@syphyr
Copy link
Contributor

syphyr commented Jan 3, 2025

When the TorService is rapidly restarted several times, it is still possible to crash Orbot. Also, when some pluggable transports (PT) are not reachable in Orbot, such as an expired webtunnel connection, Orbot will also crash with a similar error message like the one below. I have been looking for a solution to fix this issue and came across the following pull request from @grote (#61).

I have rebased the commits from #61 located here (https://github.com/syphyr/tor-android/commits/torservice_process/) and it seems to help with the issues mentioned above. Maybe this should be revisited? @n8fr8 @bitmold

11-02 14:02:27.647 15504 15532 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 15532 (tor)
11-02 14:02:27.764 15533 15533 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-02 14:02:27.764 15533 15533 F DEBUG   : LineageOS Version: '14.1-20241029-NIGHTLY-gts210vewifi'
11-02 14:02:27.765 15533 15533 F DEBUG   : Build fingerprint: 'samsung/gts210vewifixx/gts210vewifi:7.0/NRD90M/T813XXU2BQD3:user/release-keys'
11-02 14:02:27.765 15533 15533 F DEBUG   : Revision: '4'
11-02 14:02:27.765 15533 15533 F DEBUG   : ABI: 'arm64'
11-02 14:02:27.765 15533 15533 F DEBUG   : pid: 15504, tid: 15532, name: tor  >>> org.torproject.android <<<
11-02 14:02:27.765 15533 15533 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
11-02 14:02:27.765 15533 15533 F DEBUG   :     x0   0000000000000000  x1   0000000000003cac  x2   0000000000000006  x3   0000000000000008
11-02 14:02:27.765 15533 15533 F DEBUG   :     x4   0000000000000033  x5   000000000000002f  x6   631eff7564632c32  x7   7f7f7f7f7f7f7f7f
11-02 14:02:27.765 15533 15533 F DEBUG   :     x8   0000000000000083  x9   ffffffffffffffdf  x10  0000000000000000  x11  0000000000000001
11-02 14:02:27.766 15533 15533 F DEBUG   :     x12  ffffffffffffffff  x13  2930646233336131  x14  0000007f7ed75fd8  x15  0000007f7ed75c7c
11-02 14:02:27.766 15533 15533 F DEBUG   :     x16  0000007f7ed91ec8  x17  0000007f7ed3b828  x18  0000000000015180  x19  0000007f0ed454f8
11-02 14:02:27.766 15533 15533 F DEBUG   :     x20  0000000000000006  x21  0000007f0ed45450  x22  0000000000000016  x23  0000007f582e78c8
11-02 14:02:27.766 15533 15533 F DEBUG   :     x24  0000007f0ed454e8  x25  f20f076b69ec1c0c  x26  0000007f73bde698  x27  f20f076b69ec1c0c
11-02 14:02:27.766 15533 15533 F DEBUG   :     x28  0000000000000001  x29  0000007f0ed43f40  x30  0000007f7ed38cd0
11-02 14:02:27.766 15533 15533 F DEBUG   :     sp   0000007f0ed43f20  pc   0000007f7ed3b830  pstate 0000000060000000
11-02 14:02:27.786 15533 15533 F DEBUG   : 
11-02 14:02:27.786 15533 15533 F DEBUG   : backtrace:
11-02 14:02:27.786 15533 15533 F DEBUG   :     #00 pc 000000000006c830  /system/lib64/libc.so (tgkill+8)
11-02 14:02:27.786 15533 15533 F DEBUG   :     #01 pc 0000000000069ccc  /system/lib64/libc.so (pthread_kill+64)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #02 pc 0000000000023ea0  /system/lib64/libc.so (raise+24)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #03 pc 000000000001c924  /system/lib64/libc.so (abort+52)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #04 pc 0000000000454930  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (tor_raw_abort_+12)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #05 pc 0000000000460c90  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (tor_abort_+12)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #06 pc 00000000003c97f8  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (hs_circuitmap_init+132)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #07 pc 0000000000376ec0  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (hs_init+28)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #08 pc 00000000002e07b0  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (tor_init+128)
11-02 14:02:27.787 15533 15533 F DEBUG   :     #09 pc 00000000002e0fc8  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (tor_run_main+160)
11-02 14:02:27.788 15533 15533 F DEBUG   :     #10 pc 00000000002dfa48  /data/app/org.torproject.android-2/lib/arm64/libtor.so (offset 0x2de000) (Java_org_torproject_jni_TorService_runMain+36)
11-02 14:02:27.788 15533 15533 F DEBUG   :     #11 pc 0000000000bd08a0  /data/app/org.torproject.android-2/oat/arm64/base.odex (offset 0xa9a000)
@05nelsonm
Copy link
Contributor

05nelsonm commented Jan 3, 2025

This will continue to happen until there are C bindings that will unload libtor via dlclose after it stops, before it is started again. The tor C library uses static variables that must be re-initialized every single time. The only way is to unload and then load again at next start and obtain pointers to tor_api.h functions.

See: https://github.com/05nelsonm/kmp-tor-resource/blob/master/external/native/kmp_tor.c

@n8fr8
Copy link
Member

n8fr8 commented Jan 6, 2025

The solution to all of this is Arti, which is actually being implemented with this kind of usage and interface in mind.

For the meantime, will consider the fixes proposed above.

@syphyr
Copy link
Contributor Author

syphyr commented Jan 24, 2025

I have re-enabled rotation support in Orbot with this change and there have been no crashes so far.

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