question

Marco Baccalaro avatar image
0 Likes"
Marco Baccalaro asked Marco Baccalaro commented

Model crashing at random time

Crashing model.fsm

Hello,

I have a model that is crashing, and I struggle to debug it because it crashes every time at a different simulated time even if I repeat the random streams and I reopen the same model every time.

It can happen after soon or after many simulated days.

How can I debug such a model?

I tried to look at the event list at the moment of crash and the event log by opening the external file, but every time I see different events.

Thank you for any support you can give me.


FlexSim 24.2.1
crashing
crashing-model.fsm (21.6 MiB)
· 10
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
First get it repeating - if you see different events that's great - look at the first difference and figure out why that's happening.
0 Likes 0 ·
Marco Baccalaro avatar image Marco Baccalaro Jason Lightfoot ♦♦ commented ·
The problem is exactly that. That it doesn't repeat.

But it's not something that is not correctly reset because it doesn't repeat even by closing and reopening the same model.

What can make FlexSim not repeating even by opening and running twice the same model?

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Marco Baccalaro commented ·

Compare two event logs with different events (just run it twice and export each time). Look at the first of those events and try to determine the cause - it will vary per model. You can refer to the documentation on causes of non-repeatability here.

0 Likes 0 ·
Show more comments
Jacob Gillespie avatar image
1 Like"
Jacob Gillespie answered Marco Baccalaro commented

@Marco Baccalaro

You have discovered a couple bugs here.

The first one is being caused by the table value being accessed and cast to a boolean value. This isn't being handled correctly in the implementation of FlexScript. For now, to avoid this issue you can use comparison operators which avoids casting to a boolean.

The second bug that you demonstrated with the switch statement is caused by another trickier bug. In this case the table you are accessing is going out of scope before the value is being accessed. This is causing undefined behavior. For now, to avoid this issue we recommend assigning the table to a local variable before trying to access anything on it.

· 1
5 |100000

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

Marco Baccalaro avatar image Marco Baccalaro commented ·
Thank you very much Jacob.

I'm very happy to know that this is on the list of bugs to be solved and can contribute to make FlexSim even better.
Good work!

0 Likes 0 ·
Marco Baccalaro avatar image
0 Likes"
Marco Baccalaro answered Jeanette F commented

The crashing model.fsm

After working a lot on it, I managed to isolate the problem and find where the model crashes (hoping that this is the only reason), but I really don't understand why.

If I change this line of code

if (Table("PO Prod")[i][POPROD_COL_MDS_6_DOSINGS] || Table("PO Prod")[i][POPROD_COL_AUTO_C1_DOSINGS])

with this one

if (Table("PO Prod")[i][POPROD_COL_MDS_6_DOSINGS] > 0 || Table("PO Prod")[i][POPROD_COL_AUTO_C1_DOSINGS] > 0)

the model doesn't crash anymore.


Note that:

  • the table "PO Prod" is a bundle table, but the crash happens also when I put it back to a normal table
  • values in the table can be 0 or an integer > 1
  • The model crashes when reading the line 340 of the table at the model time 95121.58
  • The numbers on the table are 1 and 2, so the code results in if (1 || 2)
  • if I go step by step, when executing this code, it doesn't crash!


This is beyond my capability to understand it.

What am I not getting?


· 3
5 |100000

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

Marco Baccalaro avatar image Marco Baccalaro commented ·

I finally understood that the problem is the table "PO Prod".

Somehow it is corrupted and gives these very strange problems.

I now just wonder how this happens and how can we avoid this happening again.

1 Like 1 ·
Marco Baccalaro avatar image Marco Baccalaro commented ·

Another very weird thing:

The following code gives the error:

"exception: FlexScript exception: Invalid row number: 1 in Global Table "PO Prod" at MAIN:/project/exec/consolescript c: <no path> i: <no path>"

switch (Table("PO Prod")[1][POPROD_COL_PO_SEQUENCE]){
case PO_SEQUENCE_C1:
return "C1";
case PO_SEQUENCE_C2:
return "C2";
}


While this code works

int value = Table("PO Prod")[1][POPROD_COL_PO_SEQUENCE];
switch (value){
case PO_SEQUENCE_C1:
return "C1";
case PO_SEQUENCE_C2:
return "C2";
}


What's happening?

Is my model corrupted?

Did it ever happen to anyone else?

0 Likes 0 ·
Jeanette F avatar image Jeanette F ♦♦ Marco Baccalaro commented ·
Hello @Marco Baccalaro,

This has been submitted to the Development team for further investigation.

1 Like 1 ·