Fix segfault under mingw32 due to dynamic cast of invalid pointer value.

sync_cb::run_run() attempts to cast the obj field of the callback data to a
__vpiSysTaskCall pointer. But a sync_cb object is only used for simulation
time callbacks, where the obj field is (mostly) not used, so I can't see
that would ever succeed. As the obj field is not required to be set by the
user, the dynamic cast results in undefined behaviour, so mingw32 is not to
blame.

This code was introduced by Johann Klammer in commit c79df7c44, but the user
klammerj and all trace of that pull request have vanished from GitHub, and
there is no associated regression test, so I can't establish the rationale
for it.

(cherry picked from commit 8da8261fc3)
This commit is contained in:
Martin Whitaker 2020-12-02 12:27:42 +00:00
parent d0e2ed1509
commit 580170d974
1 changed files with 0 additions and 2 deletions

View File

@ -320,9 +320,7 @@ void sync_cb::run_run()
if (cur->cb_data.cb_rtn != 0) {
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = sync_flag? VPI_MODE_ROSYNC : VPI_MODE_RWSYNC;
vpip_cur_task = dynamic_cast<__vpiSysTaskCall*>(cur->cb_data.obj);
(cur->cb_data.cb_rtn)(&cur->cb_data);
vpip_cur_task = 0;
vpi_mode_flag = VPI_MODE_NONE;
}