Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when replacing net destination in python API #547

Open
MonsterDruide1 opened this issue Dec 22, 2023 · 1 comment
Open

Segfault when replacing net destination in python API #547

MonsterDruide1 opened this issue Dec 22, 2023 · 1 comment
Assignees

Comments

@MonsterDruide1
Copy link
Contributor

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:

  1. Open any netlist with at least one gate
  2. Get the ID of any net with at least one destination
  3. 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.

@joern274 joern274 self-assigned this Jan 2, 2024
@joern274
Copy link
Contributor

joern274 commented Jan 2, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants