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

[gui] full text search does not find all occurrences #812

Closed
xmhwws opened this issue Dec 23, 2019 · 8 comments
Closed

[gui] full text search does not find all occurrences #812

xmhwws opened this issue Dec 23, 2019 · 8 comments
Labels
bug Core Issues in jadx-core module

Comments

@xmhwws
Copy link

xmhwws commented Dec 23, 2019

Something similar happened before:
#803 (comment)
#742 (comment)

jadx version: dev(2019.12.23 the lastest commit!) and jadx-1.1.0-b1197-0c55ab90
Tested both my compiled jadx and the unstable version of jadx you posted

apk link: https://drive.google.com/open?id=1ZC4soMkpfcFiGwbHb3bHIm0-PjxY6AQO
apk version:3.3.227-10000227

class:com.adguard.android.n
find:joke_phrase_0
image

but in GDA:
image
Open jadx to the same location
class:com.adguard.android.ui.DrawerActivity
find:joke_phrase_0
method:protected void onPostCreate(android.os.Bundle bundle)
image

This is the third time I have encountered the same problem in jadx and I don't know what to do.
I sincerely suggest you think about it: search based on smali

@xmhwws xmhwws added Core Issues in jadx-core module bug labels Dec 23, 2019
@jpstotz jpstotz changed the title [core]find usage error!This problem appeared again! [gui] full text search does not find all occurrences Dec 23, 2019
@jpstotz
Copy link
Collaborator

jpstotz commented Dec 23, 2019

I can not reproduce this issue. I downloaded the linked APK file and opened it in jadx-1.1.0-b1197-0c55ab90 on Windows using AdoptOpenJDK 11.0.5.

Full text for joke_phrase_0 shows me 3 occurrences. The two from your screen shot plus the one in com.adguard.android.ui.DrawerActivity.

I am getting the same result when starting the same Jadx version on Ubuntu 18.04 using OpenJdk 11.0.5.

Are you sure you have assigned enough RAM/Heap for Jadx so that Jadx is able to fully decompile the app and create the full text index? If Jadx is running out of ram the full text index may be incomplete.

In my environment 4 GB max heap is sufficient to open the APK file you have posted. If you use an older Java version you may need more RAM as the memory management of older Java versions is not as good as the one from Java 11.

@xmhwws
Copy link
Author

xmhwws commented Dec 23, 2019

This is incredible, weird!

Environment: windows10 professional version 1909 (10.0.18363.535)
java version "1.8.0_181"
Java (TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot (TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
jadx version: jadx-1.1.0-b1197-0c55ab90

Using the default jadx-gui.bat, the results are as follows:
1

Modify jadx-gui.bat:
the first time:
DEFAULT_JVM_OPTS = "-Xms600M" "-Xmx8g"
the second time:
DEFAULT_JVM_OPTS = "-Xms600M" "-Xmx10g"
The results are the same twice, both are:
2

Is this error because the java version is too low?

@xmhwws
Copy link
Author

xmhwws commented Dec 23, 2019

I may find the reason, as shown in the figure:
3

Right click these two, click "Exclude", jadx will increase:
4

But I just want to exclude android.support. * and androidx. *, I didn't know that it would cause this bug before.

@skylot
Copy link
Owner

skylot commented Dec 23, 2019

I found cause of the problem:

ERROR - Index error in class: com.adguard.android.ui.DrawerActivity
jadx.core.utils.exceptions.JadxRuntimeException: JavaMethod not found by MethodNode: androidx.appcompat.app.AppCompatActivity.findViewById(int):T
	at jadx.api.JadxDecompiler.getJavaMethodByNode(JadxDecompiler.java:354)
	at jadx.api.JadxDecompiler.convertNode(JadxDecompiler.java:392)
	at jadx.api.JavaClass.getUsageMap(JavaClass.java:143)
	at jadx.gui.utils.CodeUsageInfo.processClass(CodeUsageInfo.java:39)
	at jadx.gui.jobs.IndexJob.lambda$runJob$0(IndexJob.java:44)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

This index error occur sometimes not always, and looks like it is a multithreading problem, setting threads count to 1 resolve all exceptions.

@xmhwws try to set 'Processing threads count' in preferences to 1, hope this will work as a workaround.

@xmhwws
Copy link
Author

xmhwws commented Dec 23, 2019

@skylot Thanks for your help, what you said may be a hidden bug.

I identified the problem, which is what I said earlier #812 (comment)
When I right-click on android.support, jadx excludes android, not android.support!
And com.adguard.android.ui.DrawerActivity includes android, so it may cause this bug.

As long as I un-exclude android, this problem will not exist.

Your discovery may be a new hidden bug?

@skylot
Copy link
Owner

skylot commented Dec 23, 2019

I made a fix for synchronization issue, this fix resolve exceptions for me. Please check latest unstable build.
Also, I think that excluding packages not relevant to this issue. And looks like you have wrong understating how exclude packages is work. In short: in packages list you can edit root packages to exclude separated by space. So if you want to exclude android.support.* just write android.support. If you write android this will exclude android and all sub packages like android.support. Hope this will help.

@xmhwws
Copy link
Author

xmhwws commented Dec 24, 2019

@skylot you are right.
5 threads + exclude android androidx, as shown in the figure:
2019-12-24_16-25-38

jadx still works, the search shows all results.

You say exclusion, writing android will only exclude android. * Instead of . * Android. * ? I understand it wrong.
This issue should have been resolved, so I close this issue?

@skylot
Copy link
Owner

skylot commented Dec 24, 2019

@xmhwws

You say exclusion, writing android will only exclude android. * Instead of . * Android. * ?

Yes, excluded only packages started with android. i.e in regexp syntax: ^android\..*
In java code here class excluded if:

cls.getFullName().equals(exclude) || cls.getFullName().startsWith(exclude + '.')

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

3 participants