Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.13k stars 565 forks source link

Version 1.0.1 crashes on start #22

Closed ewoks closed 7 years ago

ewoks commented 7 years ago

Configuration: macOS, Android 5.0.1, Samsung S4 Steps to reproduce:

Terminal log:

$ ./gnirehtet rt
Installing gnirehtet...
'adb' install -r gnirehtet.apk
gnirehtet.apk: 1 file pushed. 1.0 MB/s (14672 bytes in 0.014s)
    pkg: /data/local/tmp/gnirehtet.apk
Success
Starting gnirehtet...
'adb' reverse tcp:31416 tcp:31416
'adb' shell am startservice -a com.genymobile.gnirehtet.START
Starting service: Intent { act=com.genymobile.gnirehtet.START }
'java' -jar relay.jar
2017-04-13 10:44:58.803 I Main: Starting server...

Logcat:

04-13 10:44:17.664 25142-25142/? E/Zygote: MountEmulatedStorage()
04-13 10:44:17.664 25142-25142/? E/Zygote: v2
04-13 10:44:17.664 25142-25142/? I/libpersona: KNOX_SDCARD checking this for 10406
04-13 10:44:17.664 25142-25142/? I/libpersona: KNOX_SDCARD not a persona
04-13 10:44:17.724 25142-25142/? I/SELinux: Function: selinux_compare_spd_ram, SPD-policy is existed. and_ver=SEPF_GT-I9295_5.0.1 ver=51
04-13 10:44:17.724 25142-25142/? I/SELinux: Function: selinux_compare_spd_ram , priority [2] , priority version is VE=SEPF_GT-I9295_5.0.1-1_0045
04-13 10:44:17.724 25142-25142/? E/SELinux: [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
04-13 10:44:17.794 25142-25142/? D/ResourcesManager: creating new AssetManager and set to /data/app/com.genymobile.gnirehtet-1/base.apk
04-13 10:44:17.814 25142-25142/? D/GnirehtetControlService: Received request com.genymobile.gnirehtet.START
04-13 10:44:17.824 25142-25142/? D/GnirehtetControlService: VPN was already authorized
04-13 10:44:17.834 25142-25142/? D/GnirehtetService: Received request com.genymobile.gnirehtet.START_VPN
04-13 10:44:17.844 25142-25142/? W/GnirehtetService: Cannot set underlying network, API version 21 < 22
04-13 10:44:17.844 25142-25142/? D/AndroidRuntime: Shutting down VM
04-13 10:44:17.844 25142-25142/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.genymobile.gnirehtet, PID: 25142
                                                   java.lang.RuntimeException: Unable to start service com.genymobile.gnirehtet.GnirehtetService@3a1c97f3 with Intent { act=com.genymobile.gnirehtet.START_VPN cmp=com.genymobile.gnirehtet/.GnirehtetService (has extras) }: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.os.ParcelFileDescriptor.getFileDescriptor()' on a null object reference
                                                       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3324)
                                                       at android.app.ActivityThread.access$2200(ActivityThread.java:177)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:145)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5942)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileDescriptor android.os.ParcelFileDescriptor.getFileDescriptor()' on a null object reference
                                                       at com.genymobile.gnirehtet.GnirehtetService.startForwarding(GnirehtetService.java:147)
                                                       at com.genymobile.gnirehtet.GnirehtetService.startVpn(GnirehtetService.java:89)
                                                       at com.genymobile.gnirehtet.GnirehtetService.onStartCommand(GnirehtetService.java:75)
                                                       at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3307)
                                                       at android.app.ActivityThread.access$2200(ActivityThread.java:177) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:145) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5942) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at java.lang.reflect.Method.invoke(Method.java:372) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1388) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183) 
rom1v commented 7 years ago

The NullPointerException is already fixed in master by commit a2d855d, when establish() returns null.

However, if it always returns null on your device, I don't know what to do…

ewoks commented 7 years ago

hmm.. I just uninstall, restarted device and dialog to allow vpn appeared. Does that give a better clue about crash? I can add more logcat of this successful attempt if that is useful

rom1v commented 7 years ago

hmm.. I just uninstall, restarted device and dialog to allow vpn appeared.

Great, then it's ok, establish() may return null unexpectedly:

However, this method returns null if the application is not prepared or is revoked. This helps solve possible race conditions between other VPN applications.

And a2d855d handles this case. So it's fixed ;-)

ewoks commented 7 years ago

Cool. Will checkout when you publish new binaries. This is ready for closing in that case ;) Good job once again 👍