memory_libmap: update indices on design modification #4892
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As reported in #4883, indices to the pass are reused after the module is modified, leading to dangling cell pointers in ModWalker etc. This has been the case since the inception of the pass but has only recently been discovered when 901935f exposed the issue as a segfault when a
PortBit
is hashed. This issue is easily detected with valgrind but since there's limited use of valgrind in testing (vgtest
Makefile target only runs simple tests due to the runtime, for example) we've missed it. Whether this has lead to incorrect mapping results is uncertain.This PR fixes the issue by rebuilding MapWorker but only when a memory actually gets emitted modifying the design. This rebuilds all the indices used in the and resolves anything detectable by valgrind at least on a clang debug build.
For testing with the segfault repro, see #4883 and run yosys with valgrind like
valgrind yosys -p "read_verilog ...