no connection over obfs4 bridges if cache dir is corrupted

Currently starting tor-vpn with obf4 bridges enabled fails.

Three logs, the first one shows a bootstrap after the app was force quit, restarted and the the connect button was hit, the second and third shows logs when onionmasq was already running once and the reconnect button was hit.

Log 1

2024-04-11 18:41:55.027 10711-10711 onionmasq               org.torproject.vpn                   I  onionmasq_mobile: Hello from Rust!
2024-04-11 18:41:55.031 10711-10711 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: Getting reference to "org.torproject.onionmasq.OnionMasqJni" class...

2024-04-11 18:42:33.026 10711-10711 VpnStatusObservable     org.torproject.vpn                   D  status update: CONNECTING
2024-04-11 18:42:33.040 10711-10711 ConnectFragment         org.torproject.vpn                   D  setUIState: INIT --> CONNECTING
2024-04-11 18:42:33.122 10711-10711 TorVpnService           org.torproject.vpn                   D  service: onStartCommand
2024-04-11 18:42:33.155 10711-10711 TorVpnService           org.torproject.vpn                   D  service: starting vpn...
2024-04-11 18:42:33.320 10711-10786 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: Onionmasq_runProxy on Android API 25
2024-04-11 18:42:33.323 10711-10786 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: creating onion_tunnel...
2024-04-11 18:42:33.524 10711-10786 onionmasq               org.torproject.vpn                   I  arti_client::client: Running without a keystore
2024-04-11 18:42:33.535 10711-10786 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: successfully created tun interface
2024-04-11 18:42:33.535 10711-10786 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: starting onionmasq...
2024-04-11 18:42:33.535 10711-10771 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: starting bootstrap event listening ...
2024-04-11 18:42:33.543 10711-10770 onionmasq               org.torproject.vpn                   I  onion_tunnel::dns: Starting DNS manager

2024-04-11 18:42:44.989 10711-10769 onionmasq               org.torproject.vpn                   I  tor_dirmgr: Marked consensus usable.
2024-04-11 18:42:45.055 10711-10769 onionmasq               org.torproject.vpn                   I  tor_dirmgr: Loaded a good directory from cache.
2024-04-11 18:42:45.057 10711-10768 onionmasq               org.torproject.vpn                   I  onionmasq_mobile: Bootstrapping completed.
2024-04-11 18:42:45.065 10711-10711 VpnStatusObservable     org.torproject.vpn                   D  status update: CONNECTED
2024-04-11 18:42:45.072 10711-10711 ConnectFragment         org.torproject.vpn                   D  setUIState: CONNECTING --> CONNECTED
2024-04-11 18:42:46.952 10711-10771 onionmasq               org.torproject.vpn                   I  tor_dirmgr: Marked consensus usable.
2024-04-11 18:42:47.003 10711-10771 onionmasq               org.torproject.vpn                   I  tor_dirmgr: Directory is complete.attempt=1
2024-04-11 18:42:47.003 10711-10771 onionmasq               org.torproject.vpn                   I  tor_dirmgr::bootstrap: 1: Downloading a consensus.attempt=2

2024-04-11 18:43:03.567 10711-10770 onionmasq               org.torproject.vpn                   W  tor_circmgr::hspool: Too many preemptive onion service circuits failed; waiting a while.
2024-04-11 18:43:19.836 10711-10771 onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Reached circuit build retry limit, exiting...
2024-04-11 18:43:19.836 10711-10771 onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed

Log 2

2024-04-11 18:33:11.974  8798-8798  TorVpnService           org.torproject.vpn                   D  service: starting vpn...
2024-04-11 18:33:12.028  8798-8954  onionmasq               org.torproject.vpn                   D  onionmasq_mobile: Onionmasq_runProxy on Android API 25
2024-04-11 18:33:12.052  8798-8954  onionmasq               org.torproject.vpn                   D  onionmasq_mobile: creating onion_tunnel...
--------- beginning of system
2024-04-11 18:35:40.995  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.004  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.006  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.006  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr: Failed to build preemptive circuit [scrubbed]: error: Tried to find or build a circuit 6 times, but all attempts failed
                                                                                                    Attempt 1: Unable to select a guard relay: No usable guards. Rejected 11/13 as down, then 0/2 as pending, then 2/2 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 2: Unable to select a guard relay: No usable guards. Rejected 11/13 as down, then 0/2 as pending, then 2/2 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 3: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 4: Unable to select a guard relay: No usable guards. Rejected 12/13 as down, then 0/1 as pending, then 1/1 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 5: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 6: Spent too long trying to construct circuits for this request
2024-04-11 18:35:41.007  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr: Failed to build preemptive circuit [scrubbed]: error: Tried to find or build a circuit 6 times, but all attempts failed
                                                                                                    Attempt 1: Unable to select a guard relay: No usable guards. Rejected 11/13 as down, then 0/2 as pending, then 2/2 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 2: Unable to select a guard relay: No usable guards. Rejected 11/13 as down, then 0/2 as pending, then 2/2 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 3: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 4: Unable to select a guard relay: No usable guards. Rejected 12/13 as down, then 0/1 as pending, then 1/1 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 5: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 6: Spent too long trying to construct circuits for this request
2024-04-11 18:35:41.007  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr: Failed to build preemptive circuit [scrubbed]: error: Tried to find or build a circuit 6 times, but all attempts failed
                                                                                                    Attempt 1: Unable to select a guard relay: No usable guards. Rejected 11/13 as down, then 0/2 as pending, then 2/2 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 2: Unable to select a guard relay: No usable guards. Rejected 11/13 as down, then 0/2 as pending, then 2/2 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 3: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 4: Unable to select a guard relay: No usable guards. Rejected 12/13 as down, then 0/1 as pending, then 1/1 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 5: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 6: Spent too long trying to construct circuits for this request
2024-04-11 18:35:41.061  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.065  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.068  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.073  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.077  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:35:41.080  8798-8853  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:36:02.395  8798-8854  onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:36:02.396  8798-8854  onionmasq               org.torproject.vpn                   W  tor_dirmgr::bootstrap: error while downloading: error: Problem downloading directory object: Error while getting a circuit: Tried to find or build a circuit 4 times, but all attempts failed
                                                                                                    Attempt 1: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 2: Problem opening a channel to [scrubbed]: No plugin available for the transport snowflake
                                                                                                    Attempt 3: Problem opening a channel to [scrubbed]: No plugin available for the transport snowflake
                                                                                                    Attempt 4: Problem opening a channel to [scrubbed]: No plugin available for the transport snowflake

The third logs indicates that there might be a memory allocation issue (maybe additionally): 'Configuration requires exclusive access to shared state, but another instance of Arti has the lock: bridges configured', see below

Log 3

2024-04-11 18:47:14.588 10711-10786 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: Onionmasq_runProxy on Android API 25
2024-04-11 18:47:14.591 10711-10786 onionmasq               org.torproject.vpn                   D  onionmasq_mobile: creating onion_tunnel...
2024-04-11 18:47:14.799 10711-10786 onionmasq               org.torproject.vpn                   E  onionmasq_mobile::ffi: runProxy() returned error: couldn't start onionmasq proxy
                                                                                                    
                                                                                                    Caused by:
                                                                                                        0: Failed to set up Arti client: tor: operation not implemented: Error setting up the guard manager
                                                                                                        1: tor: operation not implemented: Error setting up the guard manager
                                                                                                        2: Error setting up the guard manager
                                                                                                        3: Invalid configuration
                                                                                                        4: Configuration requires exclusive access to shared state, but another instance of Arti has the lock: bridges configured
2024-04-11 18:47:15.004 10711-10769 onionmasq               org.torproject.vpn                   I  tor_dirmgr::bootstrap: 2: Downloading a consensus.attempt=2
2024-04-11 18:47:22.414 10711-10768 onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Reached circuit build retry limit, exiting...
2024-04-11 18:47:22.414 10711-10768 onionmasq               org.torproject.vpn                   W  tor_circmgr::mgr: Request failed
2024-04-11 18:47:22.415 10711-10768 onionmasq               org.torproject.vpn                   W  tor_dirmgr::bootstrap: error while downloading: error: Problem downloading directory object: Error while getting a circuit: Tried to find or build a circuit 6 times, but all attempts failed
                                                                                                    Attempt 1: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 2: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 3: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 4: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 5: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
                                                                                                    Attempt 6: Unable to select a guard relay: No usable guards. Rejected 13/13 as down, then 0/0 as pending, then 0/0 as unsuitable to purpose, then 0/0 with filter.
2024-04-11 18:47:24.031 10711-10768 onionmasq               org.torproject.vpn                   I  tor_dirmgr::bootstrap: 3: Downloading a consensus.attempt=2
Edited by cyberta