facebook / redex

A bytecode optimizer for Android apps
https://fbredex.com/
MIT License
6.03k stars 653 forks source link

when using debug_info_kind iodi2,line number from retrace stack is inaccurate. #865

Open pidanxiangjiao opened 3 months ago

pidanxiangjiao commented 3 months ago

Ref: https://github.sheincorp.cn/facebook/redex/issues/818

Hello , according to suggestions, current i use iodi2 for debug_info_kind and try to recover the stack trace with "redex/tools/python/symbolicator/symbolicator.py". i find the line number is a little bit after the right place which cause crash.

Am i config right? or iodi2 debug info could be inaccurate in some cases?

the config i use:

  "redex": {
    "passes": [
      "RegAllocPass",
      "ReduceGotosPass"
    ]
  },
    "StripDebugInfoPass": {
    "drop_all_dbg_info": false,
    "drop_local_variables": true,
    "drop_line_numbers": false,
    "drop_src_files": false,
    "use_allowlist": false,
    "cls_allowlist": [

    ],
    "drop_synth_aggressive": false,
    "drop_synth_conservative": true,
    "method_allowlist": [

    ],
    "drop_prologue_end": true,
    "drop_epilogue_begin": true,
    "drop_all_dbg_info_if_empty": true
  },
  "debug_info_kind": "iodi2",

the correct stack (retrace by r8retrace):

java.lang.NullPointerException: Attempt to invoke interface method 'xxx.save(java.lang.Object)' on a null object reference
at xxx.save(Utils.java:969) <-- correct place
at xxx.Utils.lambda$xxx$1(Utils.java:263) <-- correct place
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

inaccurate stack trace( after redex , retrace by symbolicator.py) i recovered is below, and i saw some weired string like "1a1c664416c38a8f31a661730f9fc0ba1e9f297230aed0cd05f2de4cd4225afa$0.run$bridge", there is no such string when i recover the stack with r8retrace from aab that is not be redexed.

java.lang.NullPointerException: Attempt to invoke interface method 'xxx.save(java.lang.Object)' on a null object reference
    at xxx.Utils.save(Utils.java:971) <-- the line num is after the right place
    at xxxx.Utils.lambda$xxx$1(Utils.java:269) <-- the line num is after the right place
    at xxx.Utils$$InternalSyntheticLambda$1$1a1c664416c38a8f31a661730f9fc0ba1e9f297230aed0cd05f2de4cd4225afa$0.run$bridge(Utils$$InternalSyntheticLambda$1$1a1c664416c38a8f31a661730f9fc0ba1e9f297230aed0cd05f2de4cd4225afa.java:56)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)
pidanxiangjiao commented 3 months ago

After test, i find the class that i add to proguard rules ,when cause crash , the remap linenumer of iodi2 debug_info_kind would be inaccurate ,is the " keep " in proguard rules will be conflicts with iodi2 for line number remapping?