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

local variable issue #75

Open
jaikishantulswani opened this issue Oct 10, 2018 · 22 comments
Open

local variable issue #75

jaikishantulswani opened this issue Oct 10, 2018 · 22 comments
Assignees
Labels
bug Something isn't working

Comments

@jaikishantulswani
Copy link

jaikishantulswani commented Oct 10, 2018

Hello @vincentcox ,
I am facing this error after supplying the apk
UnboundLocalError: local variable 'sorted_tosort' referenced before assignment
[WARNING] 127.0.0.1 - - [10/Oct/2018 19:35:59] code 404, message File not found

@vincentcox
Copy link
Owner

Are you using a build from the release? Or do you use the python command line?

If it's possible, I can check with your APK to debug this issue.

@vincentcox vincentcox self-assigned this Oct 10, 2018
@vincentcox vincentcox added the bug Something isn't working label Oct 10, 2018
@jaikishantulswani
Copy link
Author

Hi @vincentcox ,
Thanks for prompt reply. I am using from the command line.

@vincentcox
Copy link
Owner

What happens if you use:
python3 stacoan.py -p test-apk.apk --disable-server --disable-browser

You can also try to put your APK in the same folder as stacoan (in the src folder). then run:
python3 stacoan.py -p your-apk.apk --disable-server --disable-browser

@jaikishantulswani
Copy link
Author

Getting the same even with the test-apk.apk
`python3 stacoan.py -p test-apk.apk --disable-server --disable-browser
[INFO] Decompiling app...
[INFO] /mnt/Security/Tools/Android/StaCoAn/src/test-apk_apk/jadx_source_code
[INFO] "/mnt/Security/Tools/Android/StaCoAn/src/jadx/bin/jadx" -d "/mnt/Security/Tools/Android/StaCoAn/src/test-apk_apk/jadx_source_code" "test-apk.apk"
Invalid maximum heap size: -Xmx4g
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
[INFO] --------- JADX OUTPUT BELOW ---------

[INFO] jadx return code: 1
[INFO] Decompiling done.
[INFO] Searching trough files
[INFO] Searching done.
[INFO] start generating report
[INFO] progress: 100%
[ERROR] ERROR: Unknown error: local variable 'sorted_tosort' referenced before assignment.
`

@vincentcox
Copy link
Owner

vincentcox commented Oct 10, 2018

I know what happened. JADX could not allocate 4Gigs of memory so it didn't run. The program tries to continue anyhow and there are 0 results, which causes a for loop to not run somewhere.

Please double check that you are using 64-bit java version. JADX sets max memory heap to 4GB by default. This only possible on 64-bit java.

@jaikishantulswani
Copy link
Author

Is this issue with system architecture, as I am having 32bit system.

@vincentcox
Copy link
Owner

Indeed, it's caused by the 32 bit architecture. However, you can try to run:
set DEFAULT_JVM_OPTS="-Xms128M" "-Xmx2g"

But I am not sure if it will work because StaCoAn spawns an own subshell.

@vincentcox
Copy link
Owner

Let me know if it works. I will try to make a fix for this if it's not working.

@jaikishantulswani
Copy link
Author

Still getting the same :(

@vincentcox
Copy link
Owner

vincentcox commented Oct 11, 2018

I'll create a fix this weekend. Thanks for reporting this issue, I will let you know when the fix is available.

Note for myself:

@jaikishantulswani
Copy link
Author

Hello @vincentcox ,
Thank you for your quick & positive response on this issue.
Waiting for the fix 🔢

@vincentcox
Copy link
Owner

vincentcox commented Oct 12, 2018

Can you try the DEV branch?

git clone -b dev https://github.com/vincentcox/StaCoAn
cd StaCoAn
cd src
python3 stacoan.py -p test-apk.apk --disable-server --disable-browser

Let me know what the output is, If it works for you then I know the fix is working and I push it to the master.

@jaikishantulswani
Copy link
Author

jaikishantulswani commented Oct 14, 2018

Hi @vincentcox ,
Sorry for the delay, still getting the same issue

python3 stacoan.py -p test-apk.apk --disable-server --disable-browser
[INFO] Decompiling app...
[INFO] /mnt/Security/Tools/Android/StaCoAn/src/test-apk_apk/jadx_source_code
[INFO] "/mnt/Security/Tools/Android/StaCoAn/src/jadx/bin/jadx" -d "/mnt/Security/Tools/Android/StaCoAn/src/test-apk_apk/jadx_source_code" "test-apk.apk"
[INFO] 32 bit detected, setting max memory for java to 2G instead of 4G. This might cause problems for JADX.
Invalid maximum heap size: -Xmx4g
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
[INFO] --------- JADX OUTPUT BELOW ---------

[INFO] jadx return code: 1
[INFO] Decompiling done.
[INFO] Searching trough files
[INFO] Searching done.
[INFO] start generating report
[INFO] progress: 100%
[ERROR] ERROR: Unknown error: local variable 'sorted_tosort' referenced before assignment.

@jaikishantulswani
Copy link
Author

Hello @vincentcox ,
Any updates on this ?

@vincentcox
Copy link
Owner

Can you try the dev branch again?

git clone -b dev https://github.com/vincentcox/StaCoAn
cd StaCoAn
cd src
python3 stacoan.py -p test-apk.apk --disable-server --disable-browser

Normally it should work now because I put the variable into the command. Let me know the output if it still doesn't work, we'll figure it out!

@jaikishantulswani
Copy link
Author

Hello @vincentcox ,
Don't know why its not working on my machine ??? Still getting the same issue check this
screenshot from 2018-10-19 17-30-40

@vincentcox
Copy link
Owner

I'll download a 32 bit kali machine to figure this out. It will take me some time but I will dive into this! 💪

@jaikishantulswani
Copy link
Author

Great @vincentcox 👍

@vincentcox
Copy link
Owner

I was able to reproduce it and found the cause why our limit was not correctly applied.

You have to open src/jadx/bin/jadxand uncomment the line DEFAULT_JVM_OPTS='"-Xms128M" "-Xmx4g"'.
Then it should work (at least for me it did).

@jaikishantulswani
Copy link
Author

Hi @vincentcox ,
Thank you, it Works 👍 💯
This is the best support I ever got 💯

@vincentcox
Copy link
Owner

No problem, thank you for your patience because it took me some time to figure it out.
Soon I will push a global fix for this, but meanwhile you can use this fix to get it working for you.
Have a nice weekend!

@jaikishantulswani
Copy link
Author

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants