1

I am working on an java project (algorithmic in nature), running this project through CSV file after running few problems object, it's breaking with below error.

java(7606,0x70000fc31000) malloc: error for object 0x7ffb84747ac8: pointer being freed was not allocated set a breakpoint in malloc_error_break to debug

OS- Mac
Tried on java version 1.7 and 1.8, memory -Xms4G -Xmx4G

F0XS
  • 1,271
  • 3
  • 15
  • 19
Atiq
  • 490
  • 11
  • 28
  • Do you use native libraries? – Henry Oct 10 '17 at 07:21
  • Did you "set a breakpoint in malloc_error_break to debug"? – Andy Turner Oct 10 '17 at 07:22
  • Atiq, if you can share sources, this would be great. This way, it would be possible to reproduce the issue. If not, you can do what is advised in the error message. Take a look at my answer to get the feeling what kind of steps you have to take to correctly run JVM inside gdb and set the breakpoint in native code. – Oo.oO Oct 10 '17 at 13:19
  • This is production code, can't be shared. – Atiq Oct 17 '17 at 09:18

1 Answers1

4

You can always follow the error message and try to reproduce error inside gdb. This way, you can nail the very source of the problem. If you have JVM's crash log, core file, this would also help you investigate the source of the problem.

Take a look here:

JNI debugging – extreme way, or what your iPad mini and ssh sessions can do for you

What you want to do is to start you code in debug mode, run gdb, attach to JVM and set breakpoint as described in error message.

Then, once breakpoint is hit, you can take a look at backtrace inside JVM and see where the issue happens in Java code. To me, it seems as JVM installation related issue or native code problem.

You can also take a look here, to see how to debug mixed Java/C code (in your case you will debug whole JVM) using IntelliJ:

recipeNoD002 - Debugging JNI code with IntelliJ/CLion

Oo.oO
  • 12,464
  • 3
  • 23
  • 45