hal
hal copied to clipboard
Segfault when replacing net destination in python API
Describe the bug When running a script in the python console that replaces (remove and add) the connection to nets on one pin, HAL crashes with a segfault.
To Reproduce Steps to reproduce the behavior:
- Open any netlist with at least one gate
- Get the ID of any net with at least one destination
- Run the following script:
net = netlist.get_net_by_id(ID_FROM_EARLIER)
g = net.get_destinations()[0]
net.remove_destination(g)
net.add_destination(g.get_gate(), g.get_pin())
Expected behavior HAL should not crash. Visually/technically, nothing should happen, as we're replacing the net with the same net in this example. This is used in practice for replacing the input of one gate with a different net.
On that note, it might be helpful if some additional info for the requirements of add_destination
would be listed in the documentation. For example, that the destination endpoint should not have an existing connection, which would need to be removed before like this.
Desktop (please complete the following information):
- OS: Windows 10 => WSL with Ubuntu 22.04
- Version: 4.2.0-269-g8e8d384d1
Additional context Might be required in the Project 4 of the Hardware-Reverse-Engineering course held at RUB.
In your script g
is the endpoint of the net you are about to remove. Please keep in mind that you cannot extract any information from that endpoint after removal.
After the following modification your script works for me (ep = EndPoint, g = Gate, pn = Pin)
net = netlist.get_net_by_id(34)
ep = net.get_destinations()[0]
g = ep.get_gate() # get gate before removing endpoint
pn = ep.get_pin() # get pin before removing endpoint
net.remove_destination(ep)
net.add_destination(g,pn)