This issue tracker is closed. Please visit UPPAAL issue tracker at Github instead.

Bug 642 - memory exhausted on too many if-then-else nested statements
Summary: memory exhausted on too many if-then-else nested statements
Status: RESOLVED FIXED
Alias: None
Product: UPPAAL
Classification: Unclassified
Component: libutap (show other bugs)
Version: 4.1.20
Hardware: All All
: P5 normal
Assignee: Marius Mikučionis
URL:
Depends on:
Blocks:
 
Reported: 2017-08-29 13:34 CEST by Marius Mikučionis
Modified: 2018-06-25 11:55 CEST (History)
1 user (show)

See Also:
Architecture:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marius Mikučionis 2017-08-29 13:34:01 CEST
The following code triggers the "memory exhausted" error/crash in the parser:

int a;
int i;

void calc() {
  if (i == 1) a = 0;
  else if (i == 2) a = 0;
  else if (i == 3) a = 0;
  else if (i == 4) a = 1;
  else if (i == 5) a = 1;
  else if (i == 6) a = 1;
  else if (i == 7) a = 1;
  else if (i == 8) a = 1;
  else if (i == 9) a = 1;
  else if (i == 10) a = 1;
  else if (i == 11) a = 1;
  else if (i == 12) a = 1;
  else if (i == 13) a = 1;
  else if (i == 14) a = 1;
  else if (i == 15) a = 1;
  else if (i == 16) a = 2;
  else if (i == 17) a = 2;
  else if (i == 18) a = 3;
  else if (i == 19) a = 3;
  else if (i == 20) a = 3;
  else if (i == 21) a = 4;
  else if (i == 22) a = 4;
  else if (i == 23) a = 4;
  else if (i == 24) a = 4;
  else if (i == 25) a = 4;
  else if (i == 26) a = 4;
  else if (i == 27) a = 4;
}

The error is indicated around "i==24", which hits the stack limit bison allocates for right-recursive rules.

The solution is probably to rewrite the if-then-else rules to use left recursion (which consumes almost no stack).
Comment 1 Marius Mikučionis 2018-06-25 11:55:58 CEST
fixed in uppaal branch