bk138 / multivnc

MultiVNC is a cross-platform Multicast-enabled VNC viewer based on LibVNCClient. The desktop client runs on Unix, Mac OS X and Windows. There also is an Android client.
GNU General Public License v3.0
460 stars 66 forks source link

VNCConnService race crashes #172

Closed bk138 closed 2 years ago

bk138 commented 2 years ago

VNCConnService is still racy, sometimes NullpointerExceptions can occur.

Reported backtraces are not really helpful:

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4657)
  at android.app.ActivityThread.access$2000 (ActivityThread.java:247)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2091)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at android.app.ActivityThread.main (ActivityThread.java:7838)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)
Caused by: java.lang.NullPointerException: 
  at com.coboltforge.dontmind.multivnc.VNCConnService.onStartCommand (VNCConnService.kt:2)
  at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4639)
  at android.app.ActivityThread.access$2000 (ActivityThread.java:247)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2091)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:201)
  at android.os.Looper.loop (Looper.java:288)
  at android.app.ActivityThread.main (ActivityThread.java:7838)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1003)

Theories

bk138 commented 2 years ago

Still with 2.0.2, it's not a race. May it be https://stackoverflow.com/questions/23148677/service-onstartcommand-throwing-nullpointerexception ? Also see https://github.com/bk138/droidVNC-NG/commit/44765cfc338193fc7cc6e13f1502659cd228b29b :thinking:

gujjwal00 commented 2 years ago

One issue might be the data type for intent parameter: https://github.com/bk138/multivnc/blob/2aa9abe59ffbce9b25c279de517443a9f7f6231e/android/app/src/main/java/com/coboltforge/dontmind/multivnc/VNCConnService.kt#L90

Because Intent is used instead of Intent?, Kotlin compiler will automatically insert a null-check here. But intent parameter can be null for onStartCommand().

bk138 commented 2 years ago

One issue might be the data type for intent parameter:

https://github.com/bk138/multivnc/blob/2aa9abe59ffbce9b25c279de517443a9f7f6231e/android/app/src/main/java/com/coboltforge/dontmind/multivnc/VNCConnService.kt#L90

Because Intent is used instead of Intent?, Kotlin compiler will automatically insert a null-check here. But intent parameter can be null for onStartCommand().

You mean that's the reason it reports line 2 deep from the bowels of Kotlin instead of the line of onStartCommand()?

gujjwal00 commented 2 years ago

It might be. When I do (new VNCConnService()).onStartCommand(null, 0, 0); from any Java file, resulting exception has line number 2 but the message clearly states which argument is null. Ex:

2021-11-26 19:21:24.638 31624-31672/com.coboltforge.dontmind.multivnc E/AndroidRuntime: FATAL EXCEPTION: Thread-6
    Process: com.coboltforge.dontmind.multivnc, PID: 31624
    java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter intent
        at com.coboltforge.dontmind.multivnc.VNCConnService.onStartCommand(Unknown Source:2)
        at com.coboltforge.dontmind.multivnc.VNCConn$ServerToClientThread.run(VNCConn.java:267)
bk138 commented 2 years ago

Yeah those details are ommited by the Goog Play stack trace above 🙄

bk138 commented 2 years ago

No more reports incoming on Google Play, I rule this issue closed :hammer: