[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(long) Re: SableCC hangs when 'compiling' a grammar



Anton Spaans wrote:
> I start 'sablecc'-ing the dcl.grammar and after 6 a 7 minutes, the
> complitation hangs in - as it seems - an infinite loop. At that moment, the
> java VM uses about 178 MBytes of memory and stays there.
> 
> Is there something wrong with the grammar, and if so, why does SableCC hang
> and not report an error?

SableCC shouldn't hang on any grammar.  By desing, it should halt and
report an error if there's a problem in the grammar.

> I use the JDK 1.3 and SableCC-2.16.2. on an NT4.0 machine (SP6).

I have tried compiling your grammar on my system, [java version "1.2.2"
Classic VM (build 1.2.2-L, green threads, javacomp)], with:
$ java -Xmx1024m -jar sablecc.jar grammar.sablecc
and it halted normally (i.e. as a VM should do in such a situation) with
an "OutOfMemoryError" error.

Then, I tried it on one of our Sable computers that had more RAM.  It
ran [java version "1.2" Classic VM (build Linux_JDK_1.2_pre-release-v1,
native threads, sunwjit)].  I used the command:
$ java -verbose:gc -Xmx1024m -Xms128m -jar lib/sablecc.jar test.sablecc

Interestingly, the result was:
.............<GC: managing allocation failure: need 1032 bytes, type=1,
action=1>
<GC: 27797 milliseconds since last GC>
<GC: freed 1307330 objects, 96844456 bytes in 1216 ms, 90% free
(96846232/107374176)>
  <GC: init&scan: 37 ms, scan handles: 477 ms, sweep: 702 ms, compact: 0
ms>
  <GC: 0 register-marked objects, 6 stack-marked objects>
  <GC: 0 register-marked handles, 117 stack-marked handles>
  <GC: refs: soft 0 (age >= 32), weak 0, final 0, phantom 0>
..............................Segmentation fault
$

So, let's forget about this buggy "pre-release" version...

Now, I also ran it on [Java(TM) 2 Runtime Environment, Standard Edition
(build 1.3.0_02) Java HotSpot(TM) Client VM (build 1.3.0_02, mixed
mode)].  It seemed to do the same as on your NT system and freeze.  So,
I ran it again with:
$ java -Xmixed -Xdebug -Xrunjdwp
transport=dt_socket,address=8000,server=y,suspend=n -Xmx1024m -jar
lib/sablecc.jar test.sablecc

Now, when it hang, I did the following (full trace):
$ jdb -attach 8000
Initializing jdb...
CompileThread0[1] threads
Group system:
    (java.lang.ref.Reference$ReferenceHandler)0x4 Reference Handler
cond. waiti
    (java.lang.ref.Finalizer$FinalizerThread)0x3  Finalizer        
cond. waiti
    (java.lang.Thread)0x2                         Signal Dispatcher
running    
    (java.lang.Thread)0x1                         CompileThread0   
running    
Group main:
    (java.lang.Thread)0x5                         main             
running    
CompileThread0[1] suspend
All threads suspended.
CompileThread0[1] where all
CompileThread0: 
Signal Dispatcher: 
Finalizer: 
  [1] java.lang.Object.wait (native method)
  [2] java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:108)
  [3] java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:123)
  [4] java.lang.ref.Finalizer$FinalizerThread.run (Finalizer.java:162)
Reference Handler: 
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:420)
  [3] java.lang.ref.Reference$ReferenceHandler.run (Reference.java:110)
main: 
  [1] java.util.Vector.elementAt (Vector.java:419)
  [2] org.sablecc.sablecc.DFA.match (DFA.java:96)
  [3] org.sablecc.sablecc.DFA.optimize (DFA.java:42)
  [4] org.sablecc.sablecc.DFA.<init> (DFA.java:19)
  [5] org.sablecc.sablecc.GenLexer.caseStart1 (GenLexer.java:87)
  [6] org.sablecc.sablecc.node.Start1.apply (Start1.java:17)
  [7] org.sablecc.sablecc.SableCC.processGrammar (SableCC.java:189)
  [8] org.sablecc.sablecc.SableCC.processGrammar (SableCC.java:138)
  [9] org.sablecc.sablecc.SableCC.main (SableCC.java:96)
CompileThread0[1] resume
All threads resumed.
> suspend 
Internal exception:
com.sun.jdi.InternalException: Unexpected JDWP Error: 113
        at
com.sun.tools.jdi.JDWPException.toJDIException(JDWPException.java:48)
        at
com.sun.tools.jdi.VirtualMachineImpl.suspend(VirtualMachineImpl.java:270)
        at
com.sun.tools.example.debug.tty.Commands.commandSuspend(Commands.java:419)
        at
com.sun.tools.example.debug.tty.TTY.executeCommand(TTY.java:355)
        at com.sun.tools.example.debug.tty.TTY.<init>(TTY.java:625)
        at com.sun.tools.example.debug.tty.TTY.main(TTY.java:924)
> threads
Group system:
    (java.lang.ref.Reference$ReferenceHandler)0x4 Reference Handler
cond. waiti
    (java.lang.ref.Finalizer$FinalizerThread)0x3  Finalizer        
cond. waiti
    (java.lang.Thread)0x2                         Signal Dispatcher
running    
    (java.lang.Thread)0x1                         CompileThread0   
running    
Group main:
    (java.lang.Thread)0x5                         main             
unknown    
> resume
All threads resumed.
> threads
Group system:
    (java.lang.ref.Reference$ReferenceHandler)0x4 Reference Handler
cond. waiti
    (java.lang.ref.Finalizer$FinalizerThread)0x3  Finalizer        
cond. waiti
    (java.lang.Thread)0x2                         Signal Dispatcher
running    
    (java.lang.Thread)0x1                         CompileThread0   
running    
Group main:
    (java.lang.Thread)0x5                         main             
unknown    
> suspend
All threads suspended.
> where all
CompileThread0: 
Signal Dispatcher: 
Finalizer: 
  [1] java.lang.Object.wait (native method)
  [2] java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:108)
  [3] java.lang.ref.ReferenceQueue.remove (ReferenceQueue.java:123)
  [4] java.lang.ref.Finalizer$FinalizerThread.run (Finalizer.java:162)
Reference Handler: 
  [1] java.lang.Object.wait (native method)
  [2] java.lang.Object.wait (Object.java:420)
  [3] java.lang.ref.Reference$ReferenceHandler.run (Reference.java:110)
main: 
Current thread isn't suspended.
> 

--------------------------------

My guess:  This is a VM bug.
Speculative guess:  The VM ran out of "light/thin/whatever is used in
HotSpot" locks...

Please submit a bug to Sun about this. :-)

Etienne
-- 
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                             http://www.sablecc.org/
and SableVM:                                   http://www.sablevm.org/