Skip to content

Commit

Permalink
DPIC: reset diffstate_buffer to nullptr after free (#278)
Browse files Browse the repository at this point in the history
DPI-C functions are using the diffstate_buffer to check whether
the corresponding data structures have been initialized. However,
we are not resetting it to nullptr after free. If the simulation
environment is reset manually and restarted, then this pointer
will be a dangling pointer and corrupt the next DPI-C calls.
  • Loading branch information
poemonsense authored Jan 31, 2024
1 parent 4d09d49 commit 4c5b628
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/scala/DPIC.scala
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,13 @@ object DPIC {
| diffstate_buffer[i] = new DPICBuffer;
| }
|}
|
|void diffstate_buffer_free() {
| for (int i = 0; i < NUM_CORES; i++) {
| delete diffstate_buffer[i];
| }
| delete[] diffstate_buffer;
| diffstate_buffer = nullptr;
|}
""".stripMargin
interfaceCpp += interfaces.map(_._3).mkString("")
Expand Down

0 comments on commit 4c5b628

Please sign in to comment.