Skip to content

Endless loop and system crash with factorial and double equality operator #136

@fdmoulin

Description

@fdmoulin

Issue title:

Endless loop and system crash when factorial is used with a double equality operator

Issue content:

When calculating an expression that contains a factorial and evaluating with the double equality operator ==, an endless loop is triggered.

If bug/question:

  • MathParser.org-mXparser-jdk18-4.1.1
  • Framework: java 8
  • Problem description

The == operator seems to be throwing factorials for a loop (pun intended). Not sure if == is an accepted operator in this library, but it's common enough in most programming languages to make this a serious risk of being used inadvertently. The single = operator seems to work fine, and the problem doesn't occur when the factorial is wrapped in parentheses.

  • Code example:
    new Expression("5! = 120").calculate(); // OK
    new Expression("(5!) == 120").calculate(); // OK
    new Expression("5! == 120").calculate(); // creates endless recursion? loop draining CPU

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions