Skip to content

LinkedList`s removeAll method and default deinit may cause stack overflow #996

New issue

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

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

Already on GitHub? # to your account

Open
NickMeepo opened this issue Mar 30, 2022 · 0 comments
Open

Comments

@NickMeepo
Copy link

When triggering removeAll or deinit of very long LinkedList ( like 1...10000000 integers storage),you will get stack overflow. The reason is nodes` recursive releasing.

image

From the image above you will see recursive node deinit pushing into the stack accumulatively and this will cause crash with size increasing.

I suggest to fix this issue by rewriting removeAll, not simply 'self.head = nil', but using a while-loop to releasing each node, and calling removeAll in LinkedList deinit.

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

No branches or pull requests

1 participant