Skip to content

Commit

Permalink
Assert number of base clocks equals initialized base clocks. (#10910)
Browse files Browse the repository at this point in the history
- Prevents segmentation faults, but doesn't fix the underlying issue.
  • Loading branch information
AnHeuermann committed Jul 3, 2023
1 parent cf7a810 commit e015287
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions OMCompiler/Compiler/Template/CodegenC.tpl
Expand Up @@ -330,6 +330,7 @@ template functionInitSynchronous(list<ClockedPartition> clockedPartitions, Strin
void <%symbolName(modelNamePrefix,"function_initSynchronous")%>(DATA *data, threadData_t *threadData)
{
TRACE_PUSH
assertStreamPrint(threadData, data->modelData->nBaseClocks==<%listLength(clockedPartitions)%>, "Number of base clocks doens't match numer of clocks that are initialized! Code generation error!");
data->simulationInfo->baseClocks = calloc(<%listLength(clockedPartitions)%>, sizeof(BASECLOCK_DATA));

<%body%>
Expand Down
Expand Up @@ -59,6 +59,7 @@ void initSynchronous(DATA* data, threadData_t *threadData, modelica_real startTi
/* Error check */
for(i=0; i<data->modelData->nBaseClocks; i++) {
for(j=0; j<data->simulationInfo->baseClocks[i].nSubClocks; j++) {
assertStreamPrint(threadData, data->simulationInfo->baseClocks[i].subClocks != NULL, "Initialization of synchronous systems failed: baseclocks[%i]->subClocks is NULL!", i);
assertStreamPrint(threadData, data->simulationInfo->baseClocks[i].subClocks[j].solverMethod != NULL, "Continuous clocked systems aren't supported yet.");
assertStreamPrint(threadData, floorRat(data->simulationInfo->baseClocks[i].subClocks[j].shift) >= 0, "Shift of sub-clock is negative. Sub-clocks aren't allowed to fire before base-clock.");
}
Expand Down

0 comments on commit e015287

Please sign in to comment.