Closed toddstrader closed 3 years ago
Reading the comments on the Verilator PR, it would seem this was a bug in your test, no?
I must confess that I'm still not seeing where the double free is coming from in the Verilator test. But Wilson does think it's an issue with the Verilator test code, so I imagine he's right. If I had more time I'd strip down the test code and figure out what I'm missing, but unfortunately that's not the rabbit hole I'm trying to go down right now.
Sorry for the noise.
From what I read, and the brief look I took at the code, I think the problem was that the TestVpiHandle destructor was calling vpi_free_object on the VPI handle it had stored. But if you use vpi_scan in a loop until it returns NULL, the handle you have is no longer valid (and gets automatically freed by the VPI runtime). You should only manually free the handle if you exit the iterate loop before you have scanned all the objects.
I was working on a Verilator VPI test and comparing against iverilog when I hit this:
If you checkout the PR below (or wait for it to land) you can run this to reproduce the problem:
And if you run this, you'll skip the two calls to
vpi_free_object()
which cause the problem:And for clarity, here's what the Verilator test driver is running under the covers (in the
test_regress
directory):For reference: https://github.com/verilator/verilator/pull/2704