avian icon indicating copy to clipboard operation
avian copied to clipboard

Double free in invokeNative

Open mikehearn opened this issue 11 years ago • 4 comments

I'm trying to get the bitcoinj test suite to pass under Avian. ECKeyTest fails as follows:

/Applications/Xcode.app/Contents/Developer/usr/bin/gdb --args /Users/mike/Documents/Source/avian/build/darwin-x86_64-openjdk-src/avian -Dcom.lambdaworks.jni.loader=nil -cp target/bitcoinj-0.12-SNAPSHOT-bundled.jar:/Users/mike/Downloads/junit-4.11.jar:/Users/mike/Downloads/hamcrest-core-1.3.jar:target/test-classes org.junit.runner.JUnitCore com.google.bitcoin.core.ECKeyTest

...avian(57989,0x7fff762be310) malloc: *** error for object 0x1048124a0: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug

Program received signal SIGABRT, Aborted. 0x00007fff84a70866 in __pthread_kill () (gdb) bt #0 0x00007fff84a70866 in __pthread_kill () #1 0x00007fff8bf6e35c in pthread_kill () #2 0x00007fff8e9dab1a in abort () #3 0x00007fff88c3a07f in free () #4 0x000000010002a808 in free (this=0x10480a2d0, p=0x6, size=32) at heap.cpp:1865 #5 0x0000000100031e3d in invokeNative2 inlined at /Users/mike/Documents/Source/avian/src/compile.cpp:7328 #6 0x0000000100031e3d in invokeNative (t=0x1048124a0) at compile.cpp:7539 #7 0x0000000105f9b07b in ?? ()

This is with Avian 1.0 compiled against JDK8.

I'm not sure what the best way to debug this is. Any advice appreciated. I can try to make a minimal test case: I suspect it's to do with the scrypt library, which has a JNI component (though I'm trying to disable usage of it with the property flag).

mikehearn avatar May 21 '14 17:05 mikehearn

@mikehearn, my first suggestion would be to try running it under valgrind.

(if you're on Maverics using homebrew, you'll have to install with 'brew install --HEAD valgrind')

joshuawarner32 avatar May 21 '14 17:05 joshuawarner32

Ah, and apparently there's a patch you MAY still have to apply. See https://github.com/Homebrew/homebrew/issues/23660.

Specifically, editing the formula:

def patches
  # v4 of patch for Mavericks support, cf. https://bugs.kde.org/show_bug.cgi?id=326724
  { :p0 => 'http://bugsfiles.kde.org/attachment.cgi?id=83590' }
end

joshuawarner32 avatar May 21 '14 17:05 joshuawarner32

On Wed, 21 May 2014, Mike Hearn wrote:

I'm not sure what the best way to debug this is. Any advice appreciated. I can try to make a minimal test case: I suspect it's to do with the scrypt library, which has a JNI component (though I'm trying to disable usage of it with the property flag).

A test case would be very helpful. It doesn't necessarily have to be minimal, just a complete list of steps to reproduce. Bonus points if it's reproducable on Linux :)

BTW, which version of Xcode did you use to build OpenJDK 8? Did you build it on Mavericks or an earlier version of OS X? I tried building it a few weeks ago, but my Xcode was too new, apparently.

dicej avatar May 21 '14 17:05 dicej

I used an old Xcode version. I will try and make a test case that's easier than "build bitcoinj, download junit, run one of the tests under junitrunner with avian" and then valgrind it.

mikehearn avatar May 21 '14 17:05 mikehearn