alibaba / dexposed

dexposed enable 'god' mode for single android application.
4.51k stars 1.07k forks source link

occur crash #53

Open xalexchen opened 8 years ago

xalexchen commented 8 years ago

1.when i hook a method which inside has try-catch blocked,when catch blocked raise will lead app directly crash.

  1. if inside call back method beforeHookMethod we create a exception object (new Exception()) also will cause app directly crash.it's any way to avoid or fixed it ?
hwjump commented 8 years ago

plz refer https://github.com/alibaba/dexposed/blob/master/dexposed/src/main/java/com/taobao/android/dexposed/DexposedBridge.java#L222 and https://github.com/alibaba/dexposed/blob/master/dexposed/src/main/java/com/taobao/android/dexposed/DexposedBridge.java#L256 when before and after method occur exception,it should be catched!

and if the orignal method crash,it only try catch InvocationTargetException,(https://github.com/alibaba/dexposed/blob/master/dexposed/src/main/java/com/taobao/android/dexposed/DexposedBridge.java#L243), so you should try catch your exception in your orignal method.

xalexchen commented 8 years ago

what i means is if the target method has try-catch blocked. will directly crash VM

example :

protected void beforeHookedMethod(MethodHookParam param) throws Throwable { String a = null; try { a.toString(); } catch (Exception e) { e.printStackTrace(); } Log.i("dexposed", "before"); } as you can see,we already try-catch null point exception.but when VM try to fillStackTrace will lead VM directly crashed. make sense and any help ? and the Crash log like this :

backtrace: 12-22 14:32:55.134 I/DEBUG ( 424): #00 pc 002324ee /system/lib/libart.so (art::CountStackDepthVisitor::VisitFrame()+297) 12-22 14:32:55.134 I/DEBUG ( 424): #01 pc 0022da3d /system/lib/libart.so (art::StackVisitor::WalkStack(bool)+272) 12-22 14:32:55.135 I/DEBUG ( 424): #02 pc 002388d9 /system/lib/libart.so (_jobject* art::Thread::CreateInternalStackTrace(art::ScopedObjectAccessAlreadyRunnable const&) const+76)

hwjump commented 8 years ago

Could you tell me your phone type,and the android verison?

xalexchen commented 8 years ago

nexus 5 . android 5.0