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

join() on array of 1MB string ==> java.lang.NegativeArraySizeException #4785

Closed
glurp opened this issue Sep 8, 2017 · 2 comments
Closed

Comments

@glurp
Copy link

glurp commented Sep 8, 2017

Hello,

Trying to observe JVM/JRUBY with big Heap, I meet a strange behavior when Join big data.

The Script :

p "100MB data.... with 100KB string"
s='*'*100_1000
p ((0..100).map {|ii|p ii if ii%100==0; s }.join('')).size
p ((0..500).map {|ii|p ii if ii%100==0; s }.join('')).size
p ((0..700).map {|ii|p ii if ii%100==0; s }.join('')).size
p ((0..900).map {|ii|p ii if ii%100==0; s }.join('')).size

p "1GB data.... with 1MB string"
s='*'*1000_1000
p ((0..100).map {|ii|p ii if ii%100==0; s }.join('')).size
p ((0..500).map {|ii|p ii if ii%100==0; s }.join('')).size
p ((0..700).map {|ii|p ii if ii%100==0; s }.join('')).size
p ((0..900).map {|ii|p ii if ii%100==0; s }.join('')).size

Execution;

Fri Sep 08 18:01:46 CEST 2017 : jvm ready, load ScriptingContainer...
Fri Sep 08 18:01:46 CEST 2017 : start... Fri Sep 08 18:01:46 CEST 2017
"100MB data.... with 100KB string"
0
100
101101000
0
100
200
300
400
500
501501000
0
100
200
300
400
500
600
700
701701000
0
100
200
300
400
500
600
700
800
900
901901000

"1GB data.... with 1MB string"
0
100
1010101000
0
100
200
300
400
500
Exception in thread "main" org.jruby.embed.EvalFailedException: java.lang.NegativeArraySizeException
	at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:137)
	at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1307)
	at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1300)
	at vanilla.TestRedBridge.main1(TestRedBridge.java:44)
	at vanilla.TestRedBridge.main(TestRedBridge.java:49)
Caused by: java.lang.NegativeArraySizeException
	at org.jruby.util.ByteList.ensure(ByteList.java:341)
	at org.jruby.util.io.EncodingUtils.strBufCat(EncodingUtils.java:1702)
	at org.jruby.util.io.EncodingUtils.strBufCat(EncodingUtils.java:1687)
	at org.jruby.util.io.EncodingUtils.encCrStrBufCat(EncodingUtils.java:1815)
	at org.jruby.util.io.EncodingUtils.encCrStrBufCat(EncodingUtils.java:1737)
	at org.jruby.RubyString.cat19(RubyString.java:1336)
	at org.jruby.RubyString.cat19(RubyString.java:1325)
	at org.jruby.RubyString.append19(RubyString.java:2236)
	at org.jruby.RubyArray.joinStrings(RubyArray.java:1857)
	at org.jruby.RubyArray.join19(RubyArray.java:1949)
	at org.jruby.RubyArray$INVOKER$i$join19.call(RubyArray$INVOKER$i$join19.gen)
	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
	at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:315)
	at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
	at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:112)
	at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:99)
	at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:35)
	at org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
	at org.jruby.Ruby.runInterpreter(Ruby.java:835)
	at org.jruby.Ruby.loadFile(Ruby.java:2872)
	at org.jruby.runtime.load.LibrarySearcher$ResourceLibrary.load(LibrarySearcher.java:243)
	at org.jruby.runtime.load.LibrarySearcher$FoundLibrary.load(LibrarySearcher.java:34)
	at org.jruby.runtime.load.LoadService.load(LoadService.java:342)
	at org.jruby.RubyKernel.loadCommon(RubyKernel.java:987)
	at org.jruby.RubyKernel.load19(RubyKernel.java:979)
	at org.jruby.RubyKernel$INVOKER$s$0$1$load19.call(RubyKernel$INVOKER$s$0$1$load19.gen)
	at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:204)
	at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:200)
	at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
	at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
	at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:315)
	at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
	at org.jruby.ir.interpreter.Interpreter.INTERPRET_ROOT(Interpreter.java:112)
	at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:99)
	at org.jruby.ir.interpreter.Interpreter.execute(Interpreter.java:35)
	at org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
	at org.jruby.Ruby.runInterpreter(Ruby.java:840)
	at org.jruby.Ruby.runInterpreter(Ruby.java:844)
	at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:118)
	... 4 more

Environment

[actemium@simulateur lib]$ uname -a
Linux simulateur 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

(CENTOS 7 , 64GB RAM...)

[actemium@simulateur lib]$ free
              total        used        free      shared  buff/cache   available
Mem:       65670064     3295072    51641496      272600    10733496    61340148
Swap:      29294588           0    29294588
[actemium@simulateur lib]$ jruby -v
jruby 9.1.7.0 (2.3.1) 2017-01-11 68056ae Java HotSpot(TM) 64-Bit Server VM 25.144-b01 on 1.8.0_144-b01 +jit [linux-x86_64]
[actemium@simulateur lib]$ 
$ pgrep -laf jruby
46554 /usr/java/default/bin/java 
-Xmx20g 
-Djruby.home=/home/actemium/.rvm/rubies/jruby-9.1.7.0 
-Djruby.objectspace.enabled=false -Dfile.encoding=UTF-8 
-classpath ...:
/home/actemium/eclipse-workspace/simulateurDDS/lib/linux64/nddsjava.jar:/home/actemium/eclipse-workspace/simulateurDDS/lib/jruby-truffle.jar:/home/actemium/eclipse-workspace/simulateurDDS
/lib/jruby.jar vanilla.TestRedBridge

Java Code (RedBridge) for call JRuby;

public class TestRedBridge {
	static void prt(String t) {
		System.out.print((new Date()).toString());
		System.out.print(" : ");
		System.out.println(t);
		System.out.flush();
	}

	public static void main1(String[] args) {
		prt("jvm ready, load ScriptingContainer...");
		ScriptingContainer container = new ScriptingContainer();
		//container.setHomeDirectory("/home/actemium/.rvm/rubies/jruby-9.1.7.0"); (alternative a l'option jvm)
		
		//////////// Chargement des reperoires contenant du code ruby
		List<String> loadPaths = new ArrayList();
	    loadPaths.add("classpath/vanilla");
	    loadPaths.add("/home/actemium/bin/includes");
	    container.setLoadPaths(loadPaths);		

		prt("start... " + (new Date()).toString());
		container.runScriptlet("load 'jsim_utils.rb'");		
		container.runScriptlet("load 'test_embedded.rb'");
		prt("end.");
	}

	public static void main(String[] args) {
		main1(args);
	}
}
@glurp
Copy link
Author

glurp commented Sep 8, 2017

seem to be same issue as in #4704

@headius
Copy link
Member

headius commented Nov 1, 2017

Dupe of #4704.

@headius headius closed this as completed Nov 1, 2017
@headius headius added this to the Invalid or Duplicate milestone Nov 1, 2017
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

2 participants