Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java double free or corruption

Tags:

java

ubuntu

maybe stupid question but i'm getting randomly following error when running my *.jar package. Sometimes programm runs flawlessly and sometimes interrupts putting this out in console:

*** Error in 'java': double free or corruption (out): 0x00007f665c04a830 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80a46)[0x7f66c63d7a46]
/usr/lib/libjnetpcap.so(Java_org_jnetpcap_nio_JMemoryReference_disposeNative0+0xa6)[0x7f66b55f20eb]
[0x7f66bc5cd738]
======= Memory map: ========
00400000-00401000 r-xp 00000000 08:02 2752983                            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
00600000-00601000 r--p 00000000 08:02 2752983                            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
00601000-00602000 rw-p 00001000 08:02 2752983                            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
006d2000-006f3000 rw-p 00000000 00:00 0                                  [heap]
77b000000-77c500000 rw-p 00000000 00:00 0 
77c500000-785600000 rw-p 00000000 00:00 0 
785600000-78a780000 rw-p 00000000 00:00 0 
78a780000-7d7200000 rw-p 00000000 00:00 0 
7d7200000-7d9b00000 rw-p 00000000 00:00 0 
7d9b00000-800000000 rw-p 00000000 00:00 0 
7f664c000000-7f664c021000 rw-p 00000000 00:00 0 
7f664c021000-7f6650000000 ---p 00000000 00:00 0 
7f6654000000-7f6654021000 rw-p 00000000 00:00 0 
7f6654021000-7f6658000000 ---p 00000000 00:00 0 
7f6658000000-7f6658021000 rw-p 00000000 00:00 0 
7f6658021000-7f665c000000 ---p 00000000 00:00 0 
7f665c000000-7f665c0ac000 rw-p 00000000 00:00 0 
7f665c0ac000-7f6660000000 ---p 00000000 00:00 0 
7f6660000000-7f6660021000 rw-p 00000000 00:00 0 
7f6660021000-7f6664000000 ---p 00000000 00:00 0 
7f6664000000-7f66641ad000 rw-p 00000000 00:00 0 
7f66641ad000-7f6668000000 ---p 00000000 00:00 0 
7f6668000000-7f6668021000 rw-p 00000000 00:00 0 
7f6668021000-7f666c000000 ---p 00000000 00:00 0 
7f666c000000-7f666c021000 rw-p 00000000 00:00 0 
7f666c021000-7f6670000000 ---p 00000000 00:00 0 
7f6670000000-7f6670021000 rw-p 00000000 00:00 0 
7f6670021000-7f6674000000 ---p 00000000 00:00 0 
7f6674000000-7f6674021000 rw-p 00000000 00:00 0 
7f6674021000-7f6678000000 ---p 00000000 00:00 0 
7f667969a000-7f667969d000 ---p 00000000 00:00 0 
7f667969d000-7f667979b000 rw-p 00000000 00:00 0                          [stack:5820]
7f667979b000-7f667979e000 ---p 00000000 00:00 0 
7f667979e000-7f667989c000 rw-p 00000000 00:00 0                          [stack:5819]
7f667989c000-7f667989f000 ---p 00000000 00:00 0 
7f667989f000-7f667999d000 rw-p 00000000 00:00 0                          [stack:5818]
7f667999d000-7f6679bbd000 rw-s 00000000 00:07 220407                     socket:[220407]
7f6679bbd000-7f6679bc0000 ---p 00000000 00:00 0 
7f6679bc0000-7f6679cbe000 rw-p 00000000 00:00 0                          [stack:5817]
7f6679cbe000-7f6679cc1000 ---p 00000000 00:00 0 
7f6679cc1000-7f6679dbf000 rw-p 00000000 00:00 0                          [stack:5816]
7f6679dbf000-7f6679fdf000 rw-s 00000000 00:07 219343                     socket:[219343]
7f6679fdf000-7f6679fe2000 ---p 00000000 00:00 0 
7f6679fe2000-7f667a0e0000 rw-p 00000000 00:00 0                          [stack:5814]
7f667a0e0000-7f667a0fb000 r--s 00000000 08:02 1970077                    /usr/share/fonts/type1/gsfonts/p052003l.pfb
7f667a0fb000-7f667a10d000 r--s 00000000 08:02 1970041                    /usr/share/fonts/type1/gsfonts/n019043l.pfb
7f667a10d000-7f667a126000 r--s 00000000 08:02 1970000                    /usr/share/fonts/type1/gsfonts/b018012l.pfb
7f667a12f000-7f667a130000 rw-p 00000000 00:00 0 
7f667a130000-7f667a133000 rw-s 00000000 00:04 17236023                   /SYSV00000000 (deleted)
7f667a133000-7f667a143000 r--s 00000000 08:02 1969994                    /usr/share/fonts/type1/gsfonts/a010033l.pfb
7f667a143000-7f667a14f000 r--s 00000000 08:02 1970025                    /usr/share/fonts/type1/gsfonts/d050000l.pfb
7f667a14f000-7f667a164000 r--s 00000000 08:02 1970006                    /usr/share/fonts/type1/gsfonts/b018032l.pfb
7f667a164000-7f667a177000 r--s 00000000 08:02 1970003                    /usr/share/fonts/type1/gsfonts/b018015l.pfb
7f667a177000-7f667a191000 r--s 00000000 08:02 1970012                    /usr/share/fonts/type1/gsfonts/c059013l.pfb
7f667a191000-7f667a1a8000 r--s 00000000 08:02 1970094                    /usr/share/fonts/type1/gsfonts/z003034l.pfb
7f667a1a8000-7f667a1c3000 r--s 00000000 08:02 1970080                    /usr/share/fonts/type1/gsfonts/p052004l.pfb
7f667a1c3000-7f667a1d4000 r--s 00000000 08:02 1970047                    /usr/share/fonts/type1/gsfonts/n019063l.pfb
7f667a1d4000-7f667a1e5000 r--s 00000000 08:02 1969997                    /usr/share/fonts/type1/gsfonts/a010035l.pfb
7f667a1e5000-7f667a1ee000 r--s 00000000 08:02 1970089                    /usr/share/fonts/type1/gsfonts/s050000l.pfb
7f667a1ee000-7f667a1fe000 r--s 00000000 08:02 1969991                    /usr/share/fonts/type1/gsfonts/a010015l.pfb
7f667a1fe000-7f667a21a000 r--s 00000000 08:02 1970086                    /usr/share/fonts/type1/gsfonts/p052024l.pfb
7f667a21a000-7f667a232000 r--s 00000000 08:02 1970022                    /usr/share/fonts/type1/gsfonts/c059036l.pfb
7f667a232000-7f667a24d000 r--s 00000000 08:02 1970083                    /usr/share/fonts/type1/gsfonts/p052023l.pfb
7f667a24d000-7f667a25f000 r--s 00000000 08:02 1970009                    /usr/share/fonts/type1/gsfonts/b018035l.pfb
7f667a25f000-7f667a26f000 r--s 00000000 08:02 1969988                    /usr/share/fonts/type1/gsfonts/a010013l.pfb
7f667a26f000-7f667a28a000 r--s 00000000 08:02 1970015                    /usr/share/fonts/type1/gsfonts/c059016l.pfb
7f667a28a000-7f667a29c000 r--s 00000000 08:02 1970044                    /usr/share/fonts/type1/gsfonts/n019044l.pfb
7f667a29c000-7f667a2af000 r--s 00000000 08:02 1970050                    /usr/share/fonts/type1/gsfonts/n019064l.pfb
7f667a2af000-7f667a2c7000 r--s 00000000 08:02 1970018                    /usr/share/fonts/type1/gsfonts/c059033l.pfb
7f667a2c7000-7f667a2e5000 r--s 00000000 08:02 1275703                    /usr/share/texmf/fonts/type1/public/lm/lmr10.pfb
7f667a2e5000-7f667a307000 r--s 00000000 08:02 1978245                    /usr/share/texmf/fonts/type1/public/tex-gyre/qplr.pfb
7f667a307000-7f667a327000 r--s 00000000 08:02 1978229                    /usr/share/texmf/fonts/type1/public/tex-gyre/qbkbi.pfb
7f667a327000-7f667a341000 r--s 00000000 08:02 1978241                    /usr/share/texmf/fonts/type1/public/tex-gyre/qagbi.pfb
7f667a341000-7f667a35c000 r--s 00000000 08:02 1275730                    /usr/share/texmf/fonts/type1/public/lm/lmtcsc10.pfb
7f667a35c000-7f667a376000 r--s 00000000 08:02 1978256                    /usr/share/texmf/fonts/type1/public/tex-gyre/qhvbi.pfb
7f667a376000-7f667a37f000 r--s 00000000 08:02 1969318                    /usr/share/fonts/X11/Type1/c0649bt_.pfb
7f667a37f000-7f667a3a1000 r--s 00000000 08:02 1275718                    /usr/share/texmf/fonts/type1/public/lm/lmtlco10.pfb
7f667a3a1000-7f667a3c1000 r--s 00000000 08:02 1978224                    /usr/share/texmf/fonts/type1/public/tex-gyre/qtmbi.pfb
7f667a3c1000-7f667a3de000 r--s 00000000 08:02 1275759                    /usr/share/texmf/fonts/type1/public/lm/lmssqbx8.pfb
7f667a3de000-7f667a3f9000 r--s 00000000 08:02 1275756                    /usr/share/texmf/fonts/type1/public/lm/lmsso10.pfb

I'm using Ubuntu 13.10 64-bit, running:

java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.13.04.2)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

Thanks for your help :)

like image 768
Marek Galinski Avatar asked Mar 18 '14 21:03

Marek Galinski


1 Answers

I know that this is an old thread but just in case someone fails in the same error.

This is a multi-threading issue with a native library you are using.

To cut the long story short, the java loads the native library into memory then it is accessed by multiple threads at the same time, then this error pops up.

A quick workaround for this issue is to mark the method that generating this error as synchronized.


Update after @kit comment.

It is not possible to run such native library in multi-threading environment.

Your options are:

  • modify the native library to make it thread-safe (if you have access to its code).
  • wrap it as an application and run multiple copies as separate processes (because native library is loaded once per process)
  • wrap it as a service and run multiple copies, talking to it using Sockets or an appropriate higher-level RPC mechanism.

Credits: Load the same dynamic library in two threads (both threads in the same JVM)

like image 91
Ahmed Hassanien Avatar answered Oct 19 '22 05:10

Ahmed Hassanien