Skip to content

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

Open
@NickMeepo

Description

@NickMeepo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions