Ballerina-lang: Infinite recursive call gives java.lang.OutOfMemoryError

Created on 11 Aug 2018  路  3Comments  路  Source: ballerina-platform/ballerina-lang

Description:

java.lang.OutOfMemoryError: GC overhead limit exceeded
Dumping heap to /usr/lib/ballerina/ballerina-0.981.0/heap-dump.hprof ...
Unable to create /usr/lib/ballerina/ballerina-0.981.0/heap-dump.hprof: Permission denied

Steps to reproduce:

Run following code

import ballerina/io;

function test(int n) returns (int) {
    if(n==1) {return 1;}
    return test(n) * n;
}

function main(string... args) {
    io:println(test(5));
}

Affected Versions:

  • Ballerina 0.981.0 on Ubuntu
AreJVMCodeGen TypBug

All 3 comments

Instead of letting bvm to go out of memory I think we need to throw an error indicating stackoverflow and terminate the program.

Mail thread[1] started in ballerina-dev group to discuss about limiting call frame depth.

[1] - https://groups.google.com/forum/#!topic/ballerina-dev/tfwUqAuvbT4

This should be fixed in the master with the PR https://github.com/ballerina-platform/ballerina-lang/pull/12642

now it should throw StackOverflow error

Was this page helpful?
0 / 5 - 0 ratings