#1142 Verify Error: Stack Size too Large

Coderz Thu 8 Jul 2010

The moment I have a method that is a little long/large, I get the Verify Error telling me that the Stack size too large.

As it is, the method already is as small as possible. How can I get past this error? I am not a master of the language yet :) so I don't know how to do it.

I know I can get past this with Java using the extended command line parameters for the JVM, but how do I specify minimum or maximum stack size for the fantom VM?

Thanks

tcolar Thu 8 Jul 2010

edit fantom_home/etc/sys/config.props

change/uncomment the line: java.options=-Xmx512M

replace 512M by whatever number of MB you want to assign.

Coderz Thu 8 Jul 2010

I edited the line with various options. The last one being java.options=-Xss1024M -Xms2048M -Xmx4096M

Still I get the error.

The default was 256M

I am running on Ubuntu 10.04 64-bit on a machine with 2 x Intel Xeon processors and 16GB of memory.

I am busy rewriting a Tomcat Servlet Application to be a standalone application using fantom, and on Tomcat the application ran fine with the Tomcat default of -Xmx1024MB

Any other suggestions?

tcolar Thu 8 Jul 2010

I would think if it uses that much stack memory, there is something wrong in your code, like infinite recursion.

I would try using using a profiler like VirsualVM to see what's going on.

tcolar Thu 8 Jul 2010

Note: you could also add the XX:+HeapDumpOnOutOfMemoryError to the fantom java command options.

With that options the JVM will create a heap dump automatically if there is an OOM.

Note that the heap dumps are huge (larger than what you assigned in -Xmx, so make sure you have the disk space or use a more reasonable -Xmx value

Most program would run fine with -Xmx64M except for unusual heavily recursive stuff like sorting algos and the like.

brian Fri 9 Jul 2010

If it is a VerfiryError then it is probably a problem with the bytecode (either compiler fcode or JVM runtime emitter). I doubt its a memory setting issue.

Do you have some code with a really big method? If you can narrow down to a single class or method, can you email me the code to take a look at?

tcolar Fri 9 Jul 2010

Ha, didn't realize that this was a compiler error, never mind.

Coderz Sat 10 Jul 2010

The problem is resolved. I had something similar to the following

class Test {

File? f
Bool test := true
Void main()
{
   if(test)
   {
      File x := File("/home/bug.file".toUri)

if (!x.exists) {

f = File("/home/bug.file".toUri)
f.out.printLine("True")
f.out.flush
}
    }
    else
    {

File x := File("/home/bug.file".toUri) if (!x.exists) {

f = File("/home/bug.file".toUri)
f.out.printLine("False")
f.out.flush

} } } }

Seems that when x and f is identical, I get the problem, although it seems fine in this example. In my code, I have exactly the same stupid code to deal with, and once I fixed it with a better way to code the above logic, the problem went away.

I can email you the exact code if you supply me with an email address.

Coderz Sat 10 Jul 2010

AAAAGGGHHH! Bad formatting :)

brian Sat 10 Jul 2010

Yes, please email me the code so I can take a look (its a bug in the compiler).

My contact info is under FAQ

brian Mon 12 Jul 2010

Promoted to ticket #1142 and assigned to brian

The compiler isn't actually calculating maxStack size. Its hard-coded to 16 in FMethod.fan. We need to actually calculate it for fcode.

I've never seen 16 exceeded, but this code has tons of local variables which does something to trigger the limit.

tcolar Mon 25 Jun 2012

Actually I juts ran into that (at runtime on windows) .... werd thing is that same code on Linux box does fine

tcolar Mon 25 Jun 2012

I've moved some code out of the "constructor" phase, into a method used post construction and then it works.

brian Tue 26 Jun 2012

@tcolar - if you have a small code sample that causes this, could you email that to me? thanks

tcolar Tue 26 Jun 2012

That's bassg code, so don't think I can ... mostly it was just caused by a LOT of code(UI initialization mostly) in the constructor

bedla Fri 30 Nov 2012

Hi, I have test case with VerifyError as a result. You can take a look at https://docs.google.com/open?id=0BxrNbksto3nQSEhrMWRnX1pSeXM . Result is:

-- Run:  toomanylocals::TooManyLocalsTest.testXmlParser...

TEST FAILED
sys::Err: java.lang.VerifyError: (class: fan/toomanylocals/TooManyLocals, method:   parseUser signature: (Lfan/xml/XElem;)Ljava/lang/String;) Stack size too large
  toomanylocals::TooManyLocalsTest.testXmlParser (TooManyLocalsTest.fan:7)
  java.lang.reflect.Method.invoke (Method.java:601)
  fan.sys.Method.invoke (Method.java:559)
  fan.sys.Method$MethodFunc.callList (Method.java:204)
  fan.sys.Method.callList (Method.java:138)
  fanx.tools.Fant.runTest (Fant.java:191)
  fanx.tools.Fant.test (Fant.java:110)
  fanx.tools.Fant.test (Fant.java:32)
  fanx.tools.Fant.run (Fant.java:284)
  fanx.tools.Fant.main (Fant.java:327)

Time: 41ms

Failed:
  toomanylocals::TooManyLocalsTest.testXmlParser

***
*** 1 FAILURES [1 tests, 0 methods, 0 verifies]
***

Login or Signup to reply.