Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createUnresolvedErrorMethod lead App crash #2143

Open
LLeavesG opened this issue Feb 9, 2025 · 1 comment
Open

createUnresolvedErrorMethod lead App crash #2143

LLeavesG opened this issue Feb 9, 2025 · 1 comment

Comments

@LLeavesG
Copy link

LLeavesG commented Feb 9, 2025

when use soot to analysis the apk and write new apk output.

java.lang.Error: Unresolved compilation error: Method <org.slf4j.impl.StaticMarkerBinder: org.slf4j.impl.StaticMarkerBinder getSingleton()> does not exist!
at org.slf4j.impl.StaticMarkerBinder.getSingleton(Unknown Source:4)
at org.slf4j.MarkerFactory.bwCompatibleGetMarkerFactoryFromBinder(Unknown Source:0)
at org.slf4j.MarkerFactory.<clinit>(Unknown Source:0)
at org.slf4j.MarkerFactory.getMarker(Unknown Source:0)
at com.mendhak.gpslogger.common.slf4j.SessionLogcatAppender.<clinit>(Unknown Source:25)
at com.mendhak.gpslogger.common.slf4j.Logs.configure(Unknown Source:164)
at com.mendhak.gpslogger.common.AppSettings.onCreate(Unknown Source:34)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
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:7872)
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:936)

cause:
The StaticMarkerBinder class has no getSingleton.
However, using Soot to handle this Apk will generate additional methods and throw an error that can't be caught.

    // orig
    private static IMarkerFactory bwCompatibleGetMarkerFactoryFromBinder() throws NoClassDefFoundError {
        try {
            return StaticMarkerBinder.getSingleton().getMarkerFactory();
        } catch (NoSuchMethodError unused) {
            return StaticMarkerBinder.SINGLETON.getMarkerFactory();
        }
    }

  // after
    public static StaticMarkerBinder getSingleton() {
        Error $r0 = new Error("Unresolved compilation error: Method <org.slf4j.impl.StaticMarkerBinder: org.slf4j.impl.StaticMarkerBinder getSingleton()> does not exist!");
        throw $r0;
    }
    
        private static IMarkerFactory bwCompatibleGetMarkerFactoryFromBinder() throws NoClassDefFoundError {
        try {
            StaticMarkerBinder $r1 = StaticMarkerBinder.getSingleton();
            IMarkerFactory $r2 = $r1.getMarkerFactory();
            return $r2;
        } catch (NoSuchMethodError e) {
            StaticMarkerBinder $r12 = StaticMarkerBinder.SINGLETON;
            IMarkerFactory $r22 = $r12.getMarkerFactory();
            return $r22;
        }
    }

Image

I think if the code fixed to NoSuchMethodError will be better.

    RefType runtimeExceptionType = RefType.v("java.lang.NoSuchMethodError");
    if (Options.v().src_prec() == Options.src_prec_dotnet) {
      runtimeExceptionType = RefType.v(DotNetBasicTypes.SYSTEM_MISSINGMETHODEXCEPTION);
    }
@StevenArzt
Copy link
Contributor

It seems that someone calls getSingleton(). Soot will therefore assume that it exists. To solve the problem, use the allow-phantom-refs option.

@MarcMil Can you have a look at changing the .net exception type as proposed? The proposal seems good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants