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

java.lang.IllegalArgumentException: newPosition > limit: (67079825 > 8454316) #1653

Closed
janecms opened this issue Aug 23, 2022 · 19 comments
Closed
Labels
bug Core Issues in jadx-core module

Comments

@janecms
Copy link

janecms commented Aug 23, 2022

version 1.4.4

The Error info
/* JADX WARN: Failed to parse debug info
java.lang.IllegalArgumentException: newPosition > limit: (67079825 > 8454316)
at java.base/java.nio.Buffer.createPositionException(Unknown Source)
at java.base/java.nio.Buffer.position(Unknown Source)
at java.base/java.nio.ByteBuffer.position(Unknown Source)
at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:564)
at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
*/

Now, I think how to resole this question.
Thanks

@janecms janecms added bug Core Issues in jadx-core module labels Aug 23, 2022
@janecms janecms changed the title [core] java.lang.IllegalArgumentException: newPosition > limit: (67079825 > 8454316) Aug 23, 2022
@skylot
Copy link
Owner

skylot commented Sep 1, 2022

Now, I think how to resole this question.

@janecms do you want to prepare a PR for that issue? PR is always welcome 🙂
Anyway, it will be nice to provide a sample, so we can reproduce/check this issue.

@sulab999
Copy link

how to resole??

@jpstotz
Copy link
Collaborator

jpstotz commented Nov 24, 2022

@sulab999 @janecms The best way to resolve an issue that is caused by a certain DEX/APK files is providing the APK file.

@janecms In your original post you wrote Now, I think how to resole this question. Most people would interpret this sentence this way "I think now I know what changes needed to be done in Jadx to resolve this issue in Jadx". Thus skyot proposed to you to open a PR. If this sentence was meant in a different way please tell it to us.

@sulab999
Copy link

sulab999 commented Dec 1, 2022

@ya121y
Copy link

ya121y commented Mar 1, 2024

Hey there! any updates about this?

@skylot
Copy link
Owner

skylot commented Mar 2, 2024

@ya121y we still do not have sample to reproduce this issue.
Sample provided by @sulab999 not having this exact issue (checked with latest unstable build).

@ya121y if you can share a sample please open a new issue, I will close this one because it is old and useless now.

@draekko
Copy link

draekko commented Sep 11, 2024

I know this was closed for lack of info but am getting it with the coospo CoospoRide app (current app com.onecoder.coosporide v2.5.31 does as well as prior versions). Was trying to figure out how it talks to my ble hardware but nothing gets decoded. App can be had off the Play store or from apkpure https://apkpure.com/coosporide/com.onecoder.coosporide

One example error message from one of the fragment classes, but this seems to happen with pretty much all the classes.

`/* JADX WARN: Failed to parse debug info
java.lang.IllegalArgumentException: newPosition > limit: (67042708 > 8843904)
at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
at java.base/java.nio.Buffer.position(Buffer.java:293)
at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
*/

@Override // androidx.fragment.app.Fragment  
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
    return null;  
}  
`

@jpstotz
Copy link
Collaborator

jpstotz commented Sep 11, 2024

@draekko Thanks for providing a sample app. Which Jadx version have you used when the posted error occurred?

I wasn't able to reproduce your problem using Jadx 1.5.0 and also not with latest stable version decompiling androidx.fragment.app.Fragment of CoospoRide_2.5.31_APKPure.apk (SHA-1 hash 9F8D9CFED84E2514EBE644235B289E26A914C41D).

@draekko
Copy link

draekko commented Sep 11, 2024

I tried 1.5.0 release which i've been using since it was released and tried the latest unstable build this morning.

Java says this

openjdk 21.0.4 2024-07-16
OpenJDK Runtime Environment (build 21.0.4+7-Ubuntu-1ubuntu224.04)
OpenJDK 64-Bit Server VM (build 21.0.4+7-Ubuntu-1ubuntu224.04, mixed mode, sharing)

Using it on latest Ubuntu 24.04.1 LTS

@draekko
Copy link

draekko commented Sep 11, 2024

hmmm seems to have a different hash as the one i extracted off the device which i got it via the play store using aurora store for v2.5.31.

7a14391791d3d9666bc784083dabd109f1a3aa8f

@draekko
Copy link

draekko commented Sep 11, 2024

Same issue with the one from apkpure version locally, same has from the version i downloaded there.

when i open up com.onecoder.coosporide.main.ChartFragment i get this for one example.

package com.onecoder.coosporide.main;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import com.onecoder.coosporide.databinding.ChartFragmentBinding;
import kotlin.Deprecated;
import kotlin.Metadata;
import kotlin.jvm.internal.DefaultConstructorMarker;

/* compiled from: ChartFragment.kt */
@Metadata(d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0007\u0018\u0000 \u00142\u00020\u0001:\u0001\u0014B\u0005\u00a2\u0006\u0002\u0010\u0002J\u0016\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\bJ\u0012\u0010\n\u001a\u00020\u000b2\b\u0010\f\u001a\u0004\u0018\u00010\rH\u0017J&\u0010\u000e\u001a\u0004\u0018\u00010\u000f2\u0006\u0010\u0010\u001a\u00020\u00112\b\u0010\u0012\u001a\u0004\u0018\u00010\u00132\b\u0010\f\u001a\u0004\u0018\u00010\rH\u0016R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082.\u00a2\u0006\u0002\n\u0000\u00a8\u0006\u0015"}, d2 = {"Lcom/onecoder/coosporide/main/ChartFragment;", "Landroidx/fragment/app/Fragment;", "()V", "binding", "Lcom/onecoder/coosporide/databinding/ChartFragmentBinding;", "createCircleGradientDrawable", "Landroid/graphics/drawable/Drawable;", "startColor", "", "endColor", "onActivityCreated", "", "savedInstanceState", "Landroid/os/Bundle;", "onCreateView", "Landroid/view/View;", "inflater", "Landroid/view/LayoutInflater;", "container", "Landroid/view/ViewGroup;", "Companion", "app_prdRelease"}, k = 1, mv = {1, 9, 0}, xi = 48)
/* loaded from: classes6.dex */
public final class ChartFragment extends Fragment {
    private ChartFragmentBinding binding;

    /* renamed from: Companion, reason: from kotlin metadata */
    public static final Companion INSTANCE = new Companion(null);
    public static final int $stable = 8;

    /* compiled from: ChartFragment.kt */
    @Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002\u00a2\u0006\u0002\u0010\u0002J\u0006\u0010\u0003\u001a\u00020\u0004\u00a8\u0006\u0005"}, d2 = {"Lcom/onecoder/coosporide/main/ChartFragment$Companion;", "", "()V", "newInstance", "Lcom/onecoder/coosporide/main/ChartFragment;", "app_prdRelease"}, k = 1, mv = {1, 9, 0}, xi = 48)
    /* loaded from: classes6.dex */
    public static final class Companion {
        /* JADX WARN: Failed to parse debug info
        java.lang.IllegalArgumentException: newPosition > limit: (67042716 > 8843904)
        	at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
        	at java.base/java.nio.Buffer.position(Buffer.java:293)
        	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
        	at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
        	at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
        	at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
        	at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
        	at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
         */
        private Companion() {
        }

        /* JADX WARN: Failed to parse debug info
        java.lang.IllegalArgumentException: newPosition > limit: (67042715 > 8843904)
        	at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
        	at java.base/java.nio.Buffer.position(Buffer.java:293)
        	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
        	at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
        	at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
        	at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
        	at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
        	at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
         */
        public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
        }

        /* JADX WARN: Failed to parse debug info
        java.lang.IllegalArgumentException: newPosition > limit: (67042714 > 8843904)
        	at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
        	at java.base/java.nio.Buffer.position(Buffer.java:293)
        	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
        	at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
        	at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
        	at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
        	at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
        	at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
         */
        public final ChartFragment newInstance() {
            return null;
        }
    }

    /* JADX WARN: Failed to parse debug info
    java.lang.IllegalArgumentException: newPosition > limit: (67042710 > 8843904)
    	at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
    	at java.base/java.nio.Buffer.position(Buffer.java:293)
    	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
    	at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
    	at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
    	at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
    	at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
    	at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
     */
    public final Drawable createCircleGradientDrawable(int startColor, int endColor) {
        return null;
    }

    /* JADX WARN: Failed to parse debug info
    java.lang.IllegalArgumentException: newPosition > limit: (67042709 > 8843904)
    	at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
    	at java.base/java.nio.Buffer.position(Buffer.java:293)
    	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
    	at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
    	at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
    	at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
    	at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
    	at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
     */
    @Override // androidx.fragment.app.Fragment
    @Deprecated(message = "Deprecated in Java")
    public void onActivityCreated(Bundle savedInstanceState) {
    }

    /* JADX WARN: Failed to parse debug info
    java.lang.IllegalArgumentException: newPosition > limit: (67042708 > 8843904)
    	at java.base/java.nio.Buffer.createPositionException(Buffer.java:318)
    	at java.base/java.nio.Buffer.position(Buffer.java:293)
    	at java.base/java.nio.ByteBuffer.position(ByteBuffer.java:1094)
    	at jadx.plugins.input.dex.sections.SectionReader.absPos(SectionReader.java:82)
    	at jadx.plugins.input.dex.sections.debuginfo.DebugInfoParser.process(DebugInfoParser.java:84)
    	at jadx.plugins.input.dex.sections.DexCodeReader.getDebugInfo(DexCodeReader.java:118)
    	at jadx.core.dex.nodes.MethodNode.getDebugInfo(MethodNode.java:626)
    	at jadx.core.dex.visitors.debuginfo.DebugInfoAttachVisitor.visit(DebugInfoAttachVisitor.java:39)
     */
    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return null;
    }
}

@draekko
Copy link

draekko commented Sep 11, 2024

Does jadx use JAVA_HOME or does it use the default path for the jdk?

Edit: nevermind i figured out it does :)

I just tried 11, 17, and 21 for openjdk java version, same results.

@jpstotz
Copy link
Collaborator

jpstotz commented Sep 11, 2024

Verified - com.onecoder.coosporide.main.ChartFragment causes multiple errors like java.lang.IllegalArgumentException: newPosition > limit: (67042709 > 8843904) in APK CoospoRide_2.5.31_APKPure.apk (SHA-1 hash 9F8D9CFED84E2514EBE644235B289E26A914C41D) from https://apkpure.com/coosporide/com.onecoder.coosporide

Tested with latest unstable Jadx-gui version.

@jpstotz jpstotz reopened this Sep 11, 2024
@draekko
Copy link

draekko commented Sep 11, 2024

As far as i can tell all the classes under com.onecoder.coosporide.* seem to be having the issue.

@jackwpa
Copy link

jackwpa commented Sep 11, 2024

It is likely to be caused by NOP padding in the method bytecode, after the return instruction. It can be seen below with JEB, with the "Show instructions in gap" option enabled.

image

@skylot
Copy link
Owner

skylot commented Sep 11, 2024

@draekko, @jpstotz thanks for sample and issue confirm

This issue caused by incorrect debug info offset in dex method code section.
(Check DEX format docs https://source.android.com/docs/core/runtime/dex-format#code-item for debug_info_off field.)
Looks like it was corrupted intentionally to disrupt decompilation or disassemble.
Anyway, such incorrect data clearly reported by ApkTool/Smali like this:

Lcom/onecoder/coosporide/main/ChartFragment;->createCircleGradientDrawable(II)Landroid/graphics/drawable/Drawable;: Invalid debug offset

So I also commit a similar check and now instead of error with stacktrace, simple warning is added:

    /* JADX WARN: Invalid debug info offset */
    public final Drawable createCircleGradientDrawable(int startColor, int endColor) {
        return null;
    }

Funny that here argument names comes from Kotlin metadata, which are not removed 🤣

@draekko
Copy link

draekko commented Sep 12, 2024

Just tried apktool and all the smali code is nop'ed out as jackpwa mentioned, any suggestions on how i might go about to retrieve the code? Thanks in advance

@skylot
Copy link
Owner

skylot commented Sep 12, 2024

any suggestions on how i might go about to retrieve the code?

@draekko looks like this is not possible using only static analysis tools like jadx, so you also need a dynamic/runtime tool like frida to catch dex files restored/decrypted at runtime. ApkId report that this apk uses Ijiami packer, so you can try to search guides to fight it.

@draekko
Copy link

draekko commented Sep 13, 2024

Thanks for the suggestion, will look into them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

7 participants