orbot icon indicating copy to clipboard operation
orbot copied to clipboard

[BUG] crash in TorControlConnection

Open n8fr8 opened this issue 2 months ago • 3 comments

Describe the Bug Found on Google Play vital statistics

Smartphone (please complete the following information): Nothing Nothing Phone (1) Android 15 (SDK 35) Version: 1770200102 (17.7.0-BETA-1-tor-0.4.8.18)Occurred: 2 days ago

Crash Logs (Advanced)

Type java.util.ConcurrentModificationException

Exception java.util.ConcurrentModificationException: at java.util.ArrayList$Itr.checkForComodification (ArrayList.java:1111) at java.util.ArrayList$Itr.next (ArrayList.java:1064) at net.freehaven.tor.control.TorControlConnection.handleEvent (TorControlConnection.java:239) at net.freehaven.tor.control.TorControlConnection.react (TorControlConnection.java:382) at net.freehaven.tor.control.TorControlConnection$ControlParseThread.run (TorControlConnection.java:352)

n8fr8 avatar Oct 20 '25 13:10 n8fr8

This is in jtorcontrol and technically not in Orbot.

for (RawEventListener rawEventListener : rawEventListeners) {
                rawEventListener.onEvent(tp, rest);
            }

bitmold avatar Oct 28 '25 13:10 bitmold

https://stackoverflow.com/questions/8104692/how-to-avoid-java-util-concurrentmodificationexception-when-iterating-through-an

bitmold avatar Oct 28 '25 13:10 bitmold

In tor-android's TorService

we remove raw event listeners in onDesotry()

@Override
    public void onDestroy() {
        super.onDestroy();
        if (torControlConnection != null) {
            torControlConnection.removeRawEventListener(startedEventListener);
        }
        if (runLock.isLocked()) {
            Log.i(TAG, "Releasing lock");
            runLock.unlock();
        }
        shutdownTor();
        broadcastStatus(TorService.this, STATUS_OFF);
    }

This java.util.ConcurrentModificationException seems to occur if the event loop posted above is actively executing while somewhere else a call to removeRawEventListener is called such as the one above

bitmold avatar Oct 28 '25 13:10 bitmold