MATLAB: Stateflow model fails on write ‘data after write error’

chartsdataerrorbuseslinkedmemorysharedstateflowstateflowfailsstorewrite

I have a harness model which uses a Stateflow model. When running the harness, it fails with this error:
An error occurred while running the simulation and the simulation was terminated
Caused by:
The block 'maneuverLogicLibHarness/maneuverLogicLib/maneuverLogicChart' is writing to the data store 'maneuverLogicLibHarness/maneuverLogicLib/maneuverLogicChart' but the block(s) 'maneuverLogicLibHarness/maneuverLogicLib/maneuverLogicChart' have already written to a portion or the entire region of this memory at time 6.66. For performance reasons, occurrences of this diagnostic for this memory at other simulation time steps will be suppressed.
The error specifies a data store, but there is no data store involved in my model (at least no explicit data store, can be some internal data store in Stateflow chart). Why is this error showing up?

Best Answer

This issue occurs due to the buses shared across linked charts using data store memory, to sync up data between them internally and the diagnostic setting not being honored. In other words, you are not using a data store explicitly but some data store is used internally to handle data sync-up in the background and this data store does not honor the diagnostic. To get rid of this error go to
'Model Configuration Parameters' > 'Diagnostic' > 'Data Validity' > 'Detect write after write' > 'Use local settings'