Model crashing at random time

Model crashing at random time

MarcoBaccalaro
Participant Participant
38 Views
18 Replies
Message 1 of 19

Model crashing at random time

MarcoBaccalaro
Participant
Participant

[ FlexSim 24.2.1 ]

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.


0 Likes
Accepted solutions (1)
39 Views
18 Replies
Replies (18)
Message 2 of 19

jason_lightfootVL7B4
Autodesk
Autodesk
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
Message 3 of 19

MarcoBaccalaro
Participant
Participant
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
Message 4 of 19

jason_lightfootVL7B4
Autodesk
Autodesk

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
Message 5 of 19

MarcoBaccalaro
Participant
Participant
As said, it’s not a normal non repeatability problem because I always restart the same model (not resetting, but opening the model again) so I should normally have the exact same list of events.

And I tried to save the logs and opened them, the events before the crash are always different.

So, my question is: what can make FlexSim crash at different times in a model that should repeat itself at each run?

0 Likes
Message 6 of 19

jason_lightfootVL7B4
Autodesk
Autodesk
The first step is to make the model repeat - even if it's only for 1 second. Then go to the next difference eg. 10 seconds until your model is repeating. Then when the crash happens you can repeat the event at which it occurs. If you're saying even the events schedule at time zero on reset are in a different order before the model even starts then this is also a clue as to what could be causing the unrepeatability.


0 Likes
Message 7 of 19

jason_lightfootVL7B4
Autodesk
Autodesk

When you open the model, do you reset it before running?

I have loaded the model, set the event log to record to 250,000 seconds, set the end time to 250,000 seconds, enabled the event log and the reset before running. I get identical events to that time.

Baccalaro_Events1.zip

0 Likes
Message 8 of 19

MarcoBaccalaro
Participant
Participant
But why the model shouldn’t repeat if every time I reopen FlexSim and the model from zero?
0 Likes
Message 9 of 19

MarcoBaccalaro
Participant
Participant
I tried both ways
0 Likes
Message 10 of 19

jason_lightfootVL7B4
Autodesk
Autodesk

Even if I do a reset and second run I still get the same events to 250,000.

At what point do you see the events diverge? Please upload your event lists or compare it with the one I sent and give us step by step instructions on how to replicate it.

0 Likes
Message 11 of 19

jason_lightfootVL7B4
Autodesk
Autodesk

I think you're saying that the logged events repeat but the crash still occurs at random times - is that correct?

I can confirm the model crashed for me at around 280,000 seconds and in another run at around 500,000 seconds.

0 Likes
Message 12 of 19

MarcoBaccalaro
Participant
Participant

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")[POPROD_COL_MDS_6_DOSINGS] || Table("PO Prod")[POPROD_COL_AUTO_C1_DOSINGS])

with this one

if (Table("PO Prod")[POPROD_COL_MDS_6_DOSINGS] > 0 || Table("PO Prod")[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?

0 Likes
Message 13 of 19

MarcoBaccalaro
Participant
Participant

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
Message 14 of 19

MarcoBaccalaro
Participant
Participant

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.

Message 15 of 19

Jeanette_Fullmer
Community Manager
Community Manager
Hello @Marco Baccalaro,

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

Message 16 of 19

Jacob_Gillespie
Autodesk
Autodesk
Accepted solution

@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.

Message 17 of 19

MarcoBaccalaro
Participant
Participant
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
Message 18 of 19

jonah_kendellR47TC
Autodesk
Autodesk

This issue has been fixed in the latest bug fix releases 24.0.7 and 24.2.3.

Message 19 of 19

MarcoBaccalaro
Participant
Participant
Super!

This was a very worrying bug. It's great to know that it has been solved.
Great job guys.

0 Likes