Skip to content

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

@Sujith-G

Description

@Sujith-G

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");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions