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

LinkageError when running Bundler in 9k #2108

Closed
iconara opened this issue Nov 5, 2014 · 7 comments
Closed

LinkageError when running Bundler in 9k #2108

iconara opened this issue Nov 5, 2014 · 7 comments

Comments

@iconara
Copy link
Contributor

iconara commented Nov 5, 2014

This has happened to me a few times when running bundle in 9k:

Java::JavaLang::LinkageError: loader (instance of  org/jruby/util/JRubyClassLoader): attempted  duplicate class definition for name: "org/bouncycastle/jcajce/provider/digest/SHA512$Digest"

Sometimes it happens, sometimes it don't. I haven't seen a pattern.

$ ruby -v
jruby 9000.dev-SNAPSHOT (2.1.2p142) 2014-11-05 624823a Java HotSpot(TM) 64-Bit Server VM 25.0-b70 on 1.8.0-b132 +jit [darwin-x86_64]
$ java -version
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
@iconara
Copy link
Contributor Author

iconara commented Nov 5, 2014

It happens almost every time I bundle for the first time in a new gemset. Sometimes I see the message more than once. I have BUNDLE_JOBS set to 8 so it wouldn't surprise me if this was a multi-threading issue.

@headius
Copy link
Member

headius commented Nov 6, 2014

@iconara oh yeah, I bet it is a threading problem then. The error is caused by trying to load openssl in multiple threads at the same time; they both end up trying to define the same class at the same time.

A little synchronization on the classloader should do it, but I'll try to sort out something a little less brutal.

@headius
Copy link
Member

headius commented Nov 6, 2014

Could you get a more complete stack trace? Try combinations of -d (debug mode causes load errors to show their exceptions) and -Xbacktrace.style=raw (shows raw JVM trace).

@headius headius added this to the JRuby 9000 milestone Nov 6, 2014
@iconara
Copy link
Contributor Author

iconara commented Nov 6, 2014

It took a few runs but finally I caught one. Feels like I got it all the time yesterday, but today it was really hard to make it happen:

https://gist.github.com/iconara/bb77e5b843de4d7a9683

Unfortunately there's no stack trace to the LinkageError. I think it's because Bundler recklessly rescues Exception during installation.

Hopefully there's something else in the output that can help you.

@iconara
Copy link
Contributor Author

iconara commented Nov 6, 2014

I patched my local Bundler to not swallow the exception and managed to get a stack trace: https://gist.github.com/iconara/bb77e5b843de4d7a9683#file-error

I also updated the gist with the full output (the LinkageError in the separate file stack trace is at the very bottom): https://gist.github.com/iconara/bb77e5b843de4d7a9683#file-full-output

@headius
Copy link
Member

headius commented Nov 6, 2014

Ok thanks...tricky one to investigate but we'll figure it out.

@mkristian
Copy link
Member

I can reproduce the error with oracle jdk7 and jdk8. open-jdk does not show errors (as often I tested it but oracle jdk immediately showed the error)

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

No branches or pull requests

3 participants