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

Double free in invokeNative #270

Open
mikehearn opened this issue May 21, 2014 · 4 comments
Open

Double free in invokeNative #270

mikehearn opened this issue May 21, 2014 · 4 comments
Labels

Comments

@mikehearn
Copy link
Contributor

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).

@joshuawarner32
Copy link
Collaborator

@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
Copy link
Collaborator

Ah, and apparently there's a patch you MAY still have to apply. See Homebrew/legacy-homebrew#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

@dicej
Copy link
Member

dicej commented May 21, 2014

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.

@mikehearn
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants