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

Process is taking huge memory due to creation of 2 billion character "<". #187

Open
Sujith-G opened this issue Feb 6, 2019 · 0 comments

Comments

@Sujith-G
Copy link

Sujith-G commented Feb 6, 2019

Issue:
Process is taking huge memory due to creation of 2 billion character "<". This will also lead to OutOfMemoryError within the process.

Reason:
In Class MediaFieldParser.java -- MediaFieldParser.mediaField()
if (Debug.parserDebug) Check is missing in the below code. dbg_leave("mediaField"); is being called without the 'if (Debug.parserDebug)' check.

    } finally {
        dbg_leave("mediaField");
    }

ParserCore.dbg_enter(String rule) are not called since debugging is not enabled at the process.
In ParserCore.dbg_leave(String rule) nesting_level variable will be decremented by one every functioncall.
Finally after 2147483647 function calls, The nesting_level variable will have -2147483648.
On the next function call -2147483648 -1, Will nesting_level variable will have the value of 2147483647.
This leads to the creation of 2147483647 characters '<' .

protected void dbg_leave(String rule) {
    StringBuilder stringBuilder = new StringBuilder();
    for (int i = 0; i < nesting_level ; i++)
        stringBuilder.append("<");

    if (debug)  {
        System.out.println(
            stringBuilder +
            rule +
            "\nlexer buffer = \n" +
            lexer.getRest());
    }
    nesting_level --;
}

Fix:
Please add if (Debug.parserDebug) in MediaFieldParser.mediaField().
} finally {
if (Debug.parserDebug)
dbg_leave("mediaField");
}

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

1 participant