Idea

Serge A avatar image
4 Likes"
Serge A suggested Serge A edited

Throw an exception when the call stack is exhausted, don't crash

To reproduce:

Create a recursive usercommand:

/** recSum */
double n = param(1);
return (n > 1) ? n + recSum(n - 1) : n;

Call recSum(aBigNumber). recSum(400) is enough to crash FlexSim on my machine.

The problems with the current behavior are:

  • Data and unsaved changes are lost.
  • Errors in user code can crash the entire process.
  • Occasionally, FlexSim configuration gets corrupted, and the all subsequent attempts to run FlexSim lead to a crash on start (known workaround: reinstall FlexSim).

Proposal:

  • throw an exception to inform the user
  • unwind the call stack

A similar `recSum(999)` in Python leads to just

RecursionError: maximum recursion depth exceeded in comparison

A similar `recSum(18000)` in Javascript/nodejs is also safe:

RangeError: Maximum call stack size exceeded
flexscriptcrash
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

No Comments

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.