jruby --1.9 : Exception in thread "RubyThread-1: threadtest.rb:1"

Markus Fischer

Usenet Archive
Joined
Feb 25, 2000
Messages
136
Reaction score
0
Hi,

the following script works under MRI 1.9, but not under jruby 1.9 (but in jruby 1.8):

require 'thread'

class MutexedBoolean
def initialize(initial_value)
@value = initial_value
@mutex = Mutex.new
end
def true?
@mutex.synchronize do
@value == true
end
end
end

threads =

run = MutexedBoolean.new(true)

Thread.abort_on_exception = true

threads << Thread.new do
while run.true?
puts "1"
sleep 1
end
end

threads << Thread.new do
while run.true?
puts "2"
sleep 1
end
end

threads.each { |t| t.join }

Here's the stacktrace I'm getting. Only the first thread runs:

Exception in thread "RubyThread-1: threadtest.rb:1"
java.lang.LinkageError: loader (instance of
org/jruby/util/JRubyClassLoader): attempted duplicate class definition for name: "threadtest$block_0$RUBY$true?" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at org.jruby.util.JRubyClassLoader.defineClass(JRubyClassLoader.java:76) at org.jruby.internal.runtime.methods.InvocationMethodFactory.endClassWithBytes(InvocationMethodFactory.java:1358) at org.jruby.internal.runtime.methods.InvocationMethodFactory.getBlockCallback19(InvocationMethodFactory.java:899) at org.jruby.javasupport.util.RuntimeHelpers.createBlockCallback19(RuntimeHelpers.java:177) at org.jruby.javasupport.util.RuntimeHelpers.createCompiledBlockBody19(RuntimeHelpers.java:292) at org.jruby.javasupport.util.RuntimeHelpers.createCompiledBlockBody19(RuntimeHelpers.java:282) at org.jruby.ast.executable.RuntimeCache.createBlockBody19(RuntimeCache.java:442) at org.jruby.ast.executable.RuntimeCache.getBlockBody19(RuntimeCache.java:85) at org.jruby.ast.executable.AbstractScript.getBlockBody190(AbstractScript.java:106) at threadtest.method__2$RUBY$true_p_(threadtest.rb:9) at threadtest$method__2$RUBY$true_p_.call(threadtest$method__2$RUBY$true_p_:65535) at threadtest$method__2$RUBY$true_p_.call(threadtest$method__2$RUBY$true_p_:65535) at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:262) at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:105) at threadtest.block_2$RUBY$__file__(threadtest.rb:31) at threadtest$block_2$RUBY$__file__.call(threadtest$block_2$RUBY$__file__:65535) at org.jruby.runtime.CompiledBlock19.yield(CompiledBlock19.java:154) at org.jruby.runtime.CompiledBlock19.call(CompiledBlock19.java:82) at org.jruby.runtime.Block.call(Block.java:89) at org.jruby.RubyProc.call(RubyProc.java:268) at org.jruby.RubyProc.call(RubyProc.java:232) at org.jruby.internal.runtime.RubyRunnable.run(RubyRunnable.java:95) at java.lang.Thread.run(Thread.java:662)

If I remove the @mutex check in true?, it works in jruby 1.9.

thanks,
- Markus
 

Charles Oliver Nutter

Usenet Archive
Joined
Oct 5, 2006
Messages
938
Reaction score
0
That's wacked. Please file a bug at http://bugs.jruby.org. Looks like a class name we're generating internally is not getting handled properly.

Hi,

the following script works under MRI 1.9, but not under jruby 1.9 (but in jruby 1.8):

require 'thread'

class MutexedBoolean
=C2=A0 =C2=A0def initialize(initial_value)
=C2=A0 =C2=A0 =C2=A0 =C2=A0@value =3D initial_value
=C2=A0 =C2=A0 =C2=A0 =C2=A0@mutex =3D Mutex.new
=C2=A0 =C2=A0end
=C2=A0 =C2=A0def true?
=C2=A0 =C2=A0 =C2=A0 do
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0@value =3D=3D true =C2=A0 =C2=A0 =C2=A0 =C2=A0end =C2=A0 =C2=A0end end

threads =3D

run =3D MutexedBoolean.new(true)

Thread.abort_on_exception =3D true

threads << Thread.new do
=C2=A0 =C2=A0while run.true?
=C2=A0 =C2=A0 =C2=A0 =C2=A0puts "1"
=C2=A0 =C2=A0 =C2=A0 =C2=A0sleep 1
=C2=A0 =C2=A0end
end

threads << Thread.new do
=C2=A0 =C2=A0while run.true?
=C2=A0 =C2=A0 =C2=A0 =C2=A0puts "2"
=C2=A0 =C2=A0 =C2=A0 =C2=A0sleep 1
=C2=A0 =C2=A0end
end

threads.each { |t| t.join }

Here's the stacktrace I'm getting. Only the first thread runs:

Exception in thread "RubyThread-1: threadtest.rb:1"
java.lang.LinkageError: loader (instance of
org/jruby/util/JRubyClassLoader): attempted =C2=A0duplicate class definit= ion for name: "threadtest$block_0$RUBY$true?" =C2=A0 =C2=A0 =C2=A0 =C2=A0at java.lang.ClassLoader.defineClass1(Native M= ethod) =C2=A0 =C2=A0 =C2=A0 =C2=A0at java.lang.ClassLoader.defineClassCond(Class= Loader.java:632) =C2=A0 =C2=A0 =C2=A0 =C2=A0at java.lang.ClassLoader.defineClass(ClassLoad= er.java:616) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.util.JRubyClassLoader.defineClass(JRubyClassLoader.java:76) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.internal.runtime.methods.InvocationMethodFactory.endClassWithBy= tes(InvocationMethodFactory.java:1358) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.internal.runtime.methods.InvocationMethodFactory.getBlockCallba= ck19(InvocationMethodFactory.java:899) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.javasupport.util.RuntimeHelpers.createBlockCallback19(RuntimeHe= lpers.java:177) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.javasupport.util.RuntimeHelpers.createCompiledBlockBody19(Runti= meHelpers.java:292) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.javasupport.util.RuntimeHelpers.createCompiledBlockBody19(Runti= meHelpers.java:282) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.ast.executable.RuntimeCache.createBlockBody19(RuntimeCache.java= :442) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.ast.executable.RuntimeCache.getBlockBody19(RuntimeCache.java:85= ) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.ast.executable.AbstractScript.getBlockBody190(AbstractScript.ja= va:106) =C2=A0 =C2=A0 =C2=A0 =C2=A0at threadtest.method__2$RUBY$true_p_(threadtes= t.rb:9) =C2=A0 =C2=A0 =C2=A0 =C2=A0at threadtest$method__2$RUBY$true_p_.call(threadtest$method__2$RUBY$true_p_:= 65535) =C2=A0 =C2=A0 =C2=A0 =C2=A0at threadtest$method__2$RUBY$true_p_.call(threadtest$method__2$RUBY$true_p_:= 65535) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.j= ava:262) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:105) =C2=A0 =C2=A0 =C2=A0 =C2=A0at threadtest.block_2$RUBY$__file__(threadtest= rb:31) =C2=A0 =C2=A0 =C2=A0 =C2=A0at threadtest$block_2$RUBY$__file__.call(threadtest$block_2$RUBY$__file__:65= 535) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.runtime.CompiledBlock19.yield(Com= piledBlock19.java:154) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.runtime.CompiledBlock19.call(Comp= iledBlock19.java:82) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.runtime.Block.call(Block.java:89) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.RubyProc.call(RubyProc.java:268) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.RubyProc.call(RubyProc.java:232) =C2=A0 =C2=A0 =C2=A0 =C2=A0at org.jruby.internal.runtime.RubyRunnable.run= (RubyRunnable.java:95) =C2=A0 =C2=A0 =C2=A0 =C2=A0at java.lang.Thread.run(Thread.java:662)

If I remove the @mutex check in true?, it works in jruby 1.9.

thanks,
- Markus
 

Markus Fischer

Usenet Archive
Joined
Feb 25, 2000
Messages
136
Reaction score
0
Fixed! Sorry I didn't update the bug until now; couldn't remember where I'd seen this email until today :)

:)

I'm happy this is solved! You don't happen to have a time frame for
1.6.3 release? ;)

thanks,
- Markus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top