pxb1988 / dex2jar

Tools to work with android .dex and java .class files
Apache License 2.0
12.36k stars 2.12k forks source link

Extra "try" got added in okio library in "okio.AsyncTimeout$Watchdog" #629

Open vramasam opened 1 month ago

vramasam commented 1 month ago

Hello @ThexXTURBOXx @pxb1988

Okhttp3 is popular network library in android, that internally depends on okio library

Its been noticed this is the original class of okio library https://github.com/square/okio/blob/master/okio/src/jvmMain/kotlin/okio/AsyncTimeout.kt

In Apk that class looks like

@Override // java.lang.Thread, java.lang.Runnable
        public void run() {
            AsyncTimeout awaitTimeout$okio;
            while (true) {
                try {
                    synchronized (AsyncTimeout.class) {
                        awaitTimeout$okio = AsyncTimeout.INSTANCE.awaitTimeout$okio();
                        if (awaitTimeout$okio == AsyncTimeout.head) {
                            Companion companion = AsyncTimeout.INSTANCE;
                            AsyncTimeout.head = null;
                            return;
                        }
                        Unit unit = Unit.INSTANCE;
                    }
                    if (awaitTimeout$okio != null) {
                        awaitTimeout$okio.timedOut();
                    }
                } catch (InterruptedException unused) {
                    continue;
                }
            }
        }

But after Dex2Jar its added try after synchronized that cause the crash in app:

@Override // java.lang.Thread, java.lang.Runnable
        public void run() {
            AsyncTimeout awaitTimeout$okio;
            while (true) {
                try {
                    synchronized (AsyncTimeout.class) {
                        try {
                            awaitTimeout$okio = AsyncTimeout.Companion.awaitTimeout$okio();
                            if (awaitTimeout$okio == AsyncTimeout.head) {
                                Companion companion = AsyncTimeout.Companion;
                                AsyncTimeout.head = null;
                                return;
                            }
                            Unit unit = Unit.INSTANCE;
                        } finally {
                        }
                    }
                    if (awaitTimeout$okio != null) {
                        awaitTimeout$okio.timedOut();
                    }
                } catch (InterruptedException e) {
                }
            }
        }

can you please check is it possible to check out this issue. I tried out with latest 2.4 SNAPSHOT issue is exist.

Exception detail because of above error: java.lang.VerifyError: Verifier rejected class okio.AsyncTimeout$Watchdog: void okio.AsyncTimeout$Watchdog.run() failed to verify: void okio.AsyncTimeout$Watchdog.run(): [0x15] expected to be within a catch-all for an instruction where a monitor is held (declaration of 'okio.AsyncTimeout$Watchdog' appears in /data/app/~~24ItOk81KC4e1c_K0I8jqA==/com.manageengine.sdp-mqW5CXPHtXWLtltZ61rpuQ==/base.apk!classes4.dex) at okio.AsyncTimeout$Companion.scheduleTimeout(Unknown Source:31) at okio.AsyncTimeout$Companion.access$scheduleTimeout(Unknown Source:0) at okio.AsyncTimeout.enter(Unknown Source:19) at okio.AsyncTimeout$sink$1.write(Unknown Source:50) at okio.RealBufferedSink.flush(Unknown Source:26) at okhttp3.internal.http1.Http1ExchangeCodec.finishRequest(Unknown Source:2) at okhttp3.internal.connection.RealConnection.createTunnel(Unknown Source:67) at okhttp3.internal.connection.RealConnection.connectTunnel(Unknown Source:19) at okhttp3.internal.connection.RealConnection.connect(Unknown Source:94) at okhttp3.internal.connection.ExchangeFinder.findConnection(Unknown Source:182) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(Unknown Source:1) at okhttp3.internal.connection.ExchangeFinder.find(Unknown Source:48) at okhttp3.internal.connection.RealCall.initExchange$okhttp(Unknown Source:32) at okhttp3.internal.connection.ConnectInterceptor.intercept(Unknown Source:14) at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80) at okhttp3.internal.cache.CacheInterceptor.intercept(Unknown Source:191) at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80) at okhttp3.internal.http.BridgeInterceptor.intercept(Unknown Source:171) at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(Unknown Source:35) at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80) at com.manageengine.sdp.rest.SDPHeaderInterceptor.intercept(Unknown Source:339) at okhttp3.internal.http.RealInterceptorChain.proceed(Unknown Source:80) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(Unknown Source:119) at okhttp3.internal.connection.RealCall$AsyncCall.run(Unknown Source:34)