NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
51.37k stars 5.85k forks source link

sleighCompile out of heap space #972

Closed rollsch closed 5 years ago

rollsch commented 5 years ago

Describe the bug Trying to build the latest ghidra commit I get a crash during the build process. Everything builds fine except for java docs.

Task :6502:sleighCompile FAILED Error occurred during initialization of VM Could not reserve enough space for 2097152KB object heap

FAILURE: Build failed with an exception.

Execution failed for task ':6502:sleighCompile'.

Process 'command 'C:\Program Files (x86)\AdoptOpenJDK\jdk-11.0.4.11-hotspot\bin\java.exe'' finished with non-zero exit value 1

Crashed during > Task :createJavadocs

To Reproduce Steps to reproduce the behavior: gradle buildGhidra

Expected behavior Doesn't crash during > Task :createJavadocs

Environment (please complete the following information):

gradle -v Kotlin: 1.3.41 Groovy: 2.5.4 Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019 JVM: 11.0.4 (AdoptOpenJDK 11.0.4+11) OS: Windows 10 10.0 x86

Is there any way to bypass building the java docs?

ryanmkurtz commented 5 years ago

gradle buildGhidra -x zipJavadocs

ryanmkurtz commented 5 years ago

How much memory does your build system have?

rollsch commented 5 years ago

32gb of RAM and a 12 core threadripper. Unsure why it is getting out of memory. I am running Windows 10 x64 1903 if that helps. I did notice that most of your build tools are the x86 versions, not x64. Could this be the issue?

I will build with the flag above.

edit: I had 16gb of RAM in use when I attempted the build. Maybe memory fragmentation means there wasn't a continuous 2gb block free to use? I'm not sure how java allocates memory.

rollsch commented 5 years ago

Update: Build still fails with -x zipJavadocs

..\ghidra>gradle buildGhidra -x zipJavadocs

> Task :6502:sleighCompile
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

> Task :6502:sleighCompile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':6502:sleighCompile'.
> Process 'command 'C:\Program Files (x86)\AdoptOpenJDK\jdk-11.0.4.11-hotspot\bin\java.exe'' finished with non-zero exit value 1
ryanmkurtz commented 5 years ago

What build tools are x86 rather than x64?

What happens if you just do:

gradle sleighCompile

ryanmkurtz commented 5 years ago

Any updates?

rollsch commented 5 years ago
\ghidra>gradle sleighCompile
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Task :6502:sleighCompile FAILED
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':6502:sleighCompile'.
> Process 'command 'C:\Program Files (x86)\AdoptOpenJDK\jdk-11.0.4.11-hotspot\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 11s
23 actionable tasks: 1 executed, 22 up-to-date

Any ideas how I can get past this? I can do a remote session with you if you have time.

ryanmkurtz commented 5 years ago

I see that your AdoptOpenJDK is in the 32-bit Program Files directory. Did you install a 32-bit or 64-bit Java?

rollsch commented 5 years ago

It seems I used the 32bit version. I am trying 64 bit now and will report back.

rollsch commented 5 years ago

Ok I tried uninstalling x86 jdk and jre and installing the x64 one and it said it could not find java despite setting the home directory and the path being correct. I installed both x64 and x86 with java home set to the x64 instance and now it runs but produces the following error:

Task :6502:sleighCompile FAILED Compiling .\data\languages\6502.slaspec: Unrecoverable error(s), halting compilation ghidra.sleigh.grammar.BailoutException: input file "...\ghidra\Ghidra\Processors\6502.\data\languages\6502.slaspec" is not properly case dependent: Case difference found: Canonical path: ...\ghidra\ghidra\Processors\6502\data\languages\6502.slaspec User path: ...\ghidra\Ghidra\Processors\6502.\data\languages\6502.slaspec

    at ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher.run_compilation(SleighCompileLauncher.java:351)
    at ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher.runMain(SleighCompileLauncher.java:227)
    at ghidra.pcodeCPort.slgh_compile.SleighCompile.main(SleighCompile.java:1691)

0 languages successfully compiled ...\ghidra\Ghidra\Processors\6502.\data\languages\6502.slaspec failed to compile 1 languages total failed to compile

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':6502:sleighCompile'.

    Process 'command 'C:\Program Files\AdoptOpenJDK\jdk-11.0.4.11-hotspot\bin\java.exe'' finished with non-zero exit value -1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 27s 74 actionable tasks: 6 executed, 68 up-to-date

rollsch commented 5 years ago

Renaming ghidra to Ghidra seemed to fix the one above.

rollsch commented 5 years ago

Ok it seems it can't handle spaces in the build path when trying to build pdb.sln as well. I'm going to be honest, this is probably the most painful project I've tried to build in a long time. Seems to be working now though. Thanks for your help!

edit: This tool really gives IDA a run for its money. Tricore support as well!

ryanmkurtz commented 5 years ago

I'd glad you got it sorted out and are liking Ghidra. I'm going to look into improving some of the roadblocks you ran into here, like having gradle print out a useful message if it's trying to use a 32-bit Java.