MVVS: MV Basic for Visual Studio

 View Only
  • 1.  StackOverflowError with code folding

    PARTNER
    Posted 12-08-2021 17:09

    When opening one of our programs in VS Code I've noticed the java process use up a large amount of system resources before eventually ending in a StackOverflowError in the folding handler.  I've reproduced this issue a few times with the same program, but no other programs seem to hit this issue.  CPU usage on the java process are between 30% and 35% with RAM usage around 1GB or higher before the process spits out the logs as pasted below.  Additionally, the WARN appears to be related to an underscore following an INPUT statement:

    INPUT NUL,1:_

    17:07:50.165 [ForkJoinPool.commonPool-worker-1] WARN  com.rs.mv.mvvs.basic.services.semantichighlighting.SemanticAnalyseVisitor - Semantic recognition error. Token type:351,Text: _
    Dec 08, 2021 5:07:50 PM org.eclipse.lsp4j.jsonrpc.RemoteEndpoint fallbackResponseError
    SEVERE: Internal error: java.lang.StackOverflowError
    java.util.concurrent.CompletionException: java.lang.StackOverflowError
    	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
    	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
    	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
    	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
    	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
    Caused by: java.lang.StackOverflowError
    	at org.antlr.v4.runtime.BufferedTokenStream.size(BufferedTokenStream.java:111)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:61)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:64)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:64)
    ...



    [Error - 5:07:50 PM] Request textDocument/foldingRange failed.
      Message: Internal error.
      Code: -32603 
    java.util.concurrent.CompletionException: java.lang.StackOverflowError
    	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:314)
    	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:319)
    	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:645)
    	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
    	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
    Caused by: java.lang.StackOverflowError
    	at org.antlr.v4.runtime.BufferedTokenStream.size(BufferedTokenStream.java:111)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:61)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:64)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:64)
    	at com.rs.mv.mvvs.basic.services.folding.handler.BaseHandler.getNextSpecificToken(BaseHandler.java:64)
    ...


    ------------------------------
    Robert Metzger
    Software Engineer
    basys Inc
    Baltimore MD US
    ------------------------------


  • 2.  RE: StackOverflowError with code folding

    ROCKETEER
    Posted 12-08-2021 19:22
    Hi Robert, 

    Thanks for your feedback! Could you help provide more detail information about the BASIC program? 
    • Does it have many INCLUDE statements?
    • The size of the program?

    And our latest build 1.3.0 will be released recently which resolves a stack overflow issue, you can also try it later.

    Thanks

    ------------------------------
    Yunpu Zhao
    Software Engineer
    Rocket Software Inc
    CN
    ------------------------------



  • 3.  RE: StackOverflowError with code folding

    PARTNER
    Posted 12-09-2021 09:44
    Good morning.  The program does not have any INCLUDE statements, and the total size is around 59KB (1653 lines.)  Other, larger programs don't seem to have this issue.  Thank you also for the good news on 1.3.0, so I'll make sure to test this scenario in that build.

    Thank you

    ------------------------------
    Robert Metzger
    Software Engineer
    basys Inc
    Baltimore MD US
    ------------------------------



  • 4.  RE: StackOverflowError with code folding

    PARTNER
    Posted 12-14-2021 14:10
    As a follow-up, testing this on 1.3.1 I'm still seeing java use considerable system resources when typing.  However, the StackOverflow error has been resolved and my programs are all getting the folding guides as expected.  I can split the system resource issue into a separate thread if preferred.

    Thank you

    ------------------------------
    Robert Metzger
    Software Engineer
    basys Inc
    Baltimore MD US
    ------------------------------



  • 5.  RE: StackOverflowError with code folding

    ROCKETEER
    Posted 12-14-2021 22:09
    Hi, Robert.

    Thanks for your feedback, for the CPU usage issue, is that only happens for the specific BASIC file or that is a general issue for all BASIC files?
    May I know the system resource information for this server? Like CPU & RAM details.

    I would like share something about our extension and hope that will help to release your concern:
    • When VS Code opening a BASIC file, the MV BASIC Extension will start to working on it(parsing the code) and that will occupy CPU and RAM resource, but as long as the parser finished work, the resource will be released then;
    • When user typing(editing) in the BASIC file, the parser also need to analyzing the input content all the time, so typing/editing in the BASIC file will also increasing the CPU usage too.

    Best Regards.
    Charles.

    ------------------------------
    Chao Han
    Rocket Internal - All Brands
    Dalian CN
    ------------------------------



  • 6.  RE: StackOverflowError with code folding

    ROCKETEER
    Posted 12-15-2021 04:56
    Robert, I would like to see this java resource problem and I will reach out to you via a mail shortly.

    ------------------------------
    Christian Bristow
    TSE
    Rocket Software Inc
    ------------------------------



  • 7.  RE: StackOverflowError with code folding

    PARTNER
    Posted 02-15-2022 10:18

    With the latest release of VSCode 1.64.2, I am no longer seeing this issue.  The following addition to VSCode appears to have resolved my issue, and the extension now runs a lot more smoothly:

    Editor adapts to language feature timings

    Extensions power almost all language features, including built-in features like folding regions, CodeLens, inlay hints, and semantic tokens. These features aren't triggered by user gestures but by typing, usually after a timeout. For instance, CodeLens updates as you type, and so does semantic tokens. The chosen timeout values had been fixed and more or less arbitrary. With this release, the editor adapts to the observed timings so that slower machines or network connections aren't overwhelmed with requests and faster machines are utilized better.



    ------------------------------
    Robert Metzger
    Software Engineer
    basys Inc
    Baltimore MD US
    ------------------------------