ModernHttpClient: SIGABRT after UnknownHostException

After making an http a call while network is disconnected, I get an UnknownHostException (which can be catched). Now turning on wifi and making the second call results in a app crash, which cannot be catched.

09-29 16:53:42.741: W/dalvikvm(14941): Invalid indirect reference 0xa2590e20 in decodeIndirectRef 09-29 16:53:42.741: I/dalvikvm(14941): "OkHttp https://*****/token" prio=5 tid=14 RUNNABLE 09-29 16:53:42.741: I/dalvikvm(14941): | group="main" sCount=0 dsCount=0 obj=0xb30f97f8 self=0xb8ff6130 09-29 16:53:42.741: I/dalvikvm(14941): | sysTid=15173 nice=0 sched=0/0 cgrp=apps handle=-1179120768 09-29 16:53:42.741: I/dalvikvm(14941): | state=R schedstat=( 49673122 22762814 2813 ) utm=4 stm=0 core=0 09-29 16:53:42.741: I/dalvikvm(14941): at md595f4b8ab717b9da13f11267a86077f20.AwaitableOkHttp_OkTaskCallback.monodroidAddReference(AwaitableOkHttp_OkTaskCallback.java:-1) 09-29 16:53:42.741: I/dalvikvm(14941): at md595f4b8ab717b9da13f11267a86077f20.AwaitableOkHttp_OkTaskCallback.n_onResponse(Native Method) 09-29 16:53:42.741: I/dalvikvm(14941): at md595f4b8ab717b9da13f11267a86077f20.AwaitableOkHttp_OkTaskCallback.onResponse(AwaitableOkHttp_OkTaskCallback.java:39) 09-29 16:53:42.741: I/dalvikvm(14941): at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:168) 09-29 16:53:42.741: I/dalvikvm(14941): at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) 09-29 16:53:42.741: I/dalvikvm(14941): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 09-29 16:53:42.741: I/dalvikvm(14941): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) 09-29 16:53:42.741: I/dalvikvm(14941): at java.lang.Thread.run(Thread.java:841) 09-29 16:53:42.741: E/dalvikvm(14941): VM aborting 09-29 16:53:42.741: A/libc(14941): Fatal signal 6 (SIGABRT) at 0x00003a5d (code=-6), thread 15173 (OkHttp Dispatch)

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 6
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I’m so sick of xamarin 😢

Hey !

I found why we have crash when okhttp throw exception : It starts here https://github.com/paulcbetts/ModernHttpClient/blob/master/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs#L184

When an exception occurs, it is set on the task. Then this exception is catch here : https://github.com/paulcbetts/ModernHttpClient/blob/master/src/ModernHttpClient/Android/OkHttpNetworkHandler.cs#L130

And when accessing the Java exception, it fails with sigsev. I think the Java collector collected the exception and we are accessing a part of the memory that we souldn’t.

What I did ; As I don’t need the typed exception, I’ve replace the tcs.TrySetException(p1) with tcs.TrySetException(new WebException(p1.Message));

I’m gonna put my version on a fork and provide a nuget package