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 with layer list manipulation while iterating #368

Closed
klayoutmatthias opened this issue Oct 1, 2019 · 1 comment
Closed

Segfault with layer list manipulation while iterating #368

klayoutmatthias opened this issue Oct 1, 2019 · 1 comment
Assignees
Milestone

Comments

@klayoutmatthias
Copy link
Collaborator

@klayoutmatthias klayoutmatthias commented Oct 1, 2019

This code segfaults on typical layer lists:

lv = pya.LayoutView.current()
  
to_delete = []
for l in lv.each_layer():
  if l.source_layer % 2 == 0:
    to_delete.append(l)

for l in to_delete:
  l.delete()

Reason: deleting a layer will invalidate the following iterators. That's reasonable, but the program should not segfault. The solution is to reverse:

...
to_delete.reverse()
for l in to_delete:
  l.delete()
@klayoutmatthias klayoutmatthias self-assigned this Nov 2, 2019
@klayoutmatthias klayoutmatthias added this to the 0.26.1 milestone Nov 2, 2019
klayoutmatthias added a commit that referenced this issue Nov 6, 2019
Implemented #368: no segfault but exception if accessing invalid laye…
@klayoutmatthias
Copy link
Collaborator Author

@klayoutmatthias klayoutmatthias commented Nov 13, 2019

Will be released soon with 0.26.1

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

1 participant