question

Shankar Narayan avatar image
5 Likes"
Shankar Narayan asked Ben Wilson edited

How can I debug a crashing FlexSim model?

Like clockwork, my FlexSim model crashes abruptly and predictably at about simulation time 7800 seconds.

Unfortunately I cannot attach the model file.

Do you have any tips for debugging a crashing model? Any help is appreciated.

crashcrashingdebugbest practicesrepeatable
5 |100000

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

1 Answer

Ben Wilson avatar image
19 Likes"
Ben Wilson answered Ben Wilson edited

Here is what our standard procedure would be if we had access to the model:

1) clean up known issues/errors. Are there ever any warnings or exceptions in the system console? If so, we track down the source of the problems and get them fixed. The Event Log may help in fixing these issues. Even though these warnings or exceptions may occur well before the time of the crash, they could still be related, and it's good practice to clean up any issues even if they are not related.

2) make the model repeatable. From FlexSim's main menu, turn on Statistics > Repeat Random Streams. Save the model with it turned on. With Repeat Random Streams turned on, make sure that the model crashes at a consistent time and note the time of the crash. If your model doesn't crash every time at the same time, your model is not repeatable. Follow the suggestions in the User Manual under Simulation Best Practices > Model Repeatability to make your model repeatable. Save the model with whatever changes were necessary to make the model repeatable.

3) find the simulation time of the crash. Open the model again, and set a stop time for some small amount of time before the crash. Run up to that point, slow the run speed, and run again, noting how far you can get before the crash. You may need to do this several times to get closer and closer to narrowing in on the exact crash time.

4) run up to the moment of the crash. Once you have pinpointed the moment of the crash, and you have run the model to some small amount of time just prior to the crash (ie. if your model crashes at time 7800.00, then set the stop time to 7799.99) - once you've run to that time just prior to the crash, open Debug > Event List to see a list of the upcoming events.

5) step to the event of the crash. Step through each scheduled event using the run controls' Step button, carefully noting which event is at the top of the list about to execute.

6) note the crash event. On one of the events, FlexSim should crash. Hopefully you took careful note of which event that was.

7) find and debug the event. Repeat steps 4-5, up until the very next step will crash FlexSim. What is the crashing event? Is there any custom code that fires as a result of that event? If so, put a breakpoint at the top of that code and then hit step to execute the next event, then debug the code.

8) track down a hiding issue. If there is no code that fires on that specific event, does that event spawn other events that happen simultaneously where there may be custom code? For instance, if the event is entry to a queue, the exit to the queue and entry to the next object down stream can all happen on the same event. Mentally follow the execution path of the event known to crash FlexSim - what else does it cause to happen immediately? Is there any custom logic along any step of that execution trail?

After you go through these steps, if you still haven't found the bug, you will at least be much closer and have a good idea of the origination of the problem. It may be that you could create a smaller sample model to send in that exhibits the same problem. Or it may be a good foundation in starting a web meeting with a member of our team to find the issue. Please contact us if you get to that point and are ready to schedule something.

· 5
5 |100000

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

Rodrigo Lamas avatar image Rodrigo Lamas commented ·

Excelent approach!

1 Like 1 ·
Joerg Vogel avatar image Joerg Vogel commented ·

@Ben Wilson, please convert your answer into an article. It is so fundamentally that it belongs to themes that I‘d like to read when I start with FlexSim and I want to know more about this program.

1 Like 1 ·
Luis T5 avatar image Luis T5 commented ·

Hello, is there anyway to debug this code, it appears on time 0, when I click into the Run model, the code appears on the System Console as Follows:


time: 0.000000 exception: Exception caught in Executive::processeventinlist(). Throwing.
time: 0.000000 exception: Exception caught in Executive::steptotime(). Throwing.
time: 0.000000 exception: Exception caught in Executive::tick(). Throwing.
time: 0.000000 exception: int runthemessageloop() #4
exception: Executive::instance.tick();
time: 0.000000 exception: int runthemessageloop() #6

Any idea what is this error related to? @Ben Wilson


0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Luis T5 commented ·

To debug an exception at time zero: In the script window write a for loop that prints the loop counter to the system console using mpt, mpd, mpr commands and include in the loop the step() command. You will then see at which step the exception occurs and can rerun changing the loop limit to be before that step. Then look at the event list to see what is the next time zero step.

3 Likes 3 ·
tannerp avatar image tannerp Luis T5 commented ·

Hi @Luis T5,

Please ask a new question as per the Answers Best Practices and reference this question. This question has already been answered and is very old, so your comment likely won't be seen.

There appears to be an infinite loop in your model. If you post a new question and attach your model, we can take a look at it. Without a model, it is impossible to debug, unfortunately.

0 Likes 0 ·