Skip to content

BUG Tree allows segfault / arbitrary memory access #2726

@jnothman

Description

@jnothman

The properties for accessing attributes on Tree return arrays which don't own their data, and which are malloced and freed by the tree. Therefore:

from sklearn.tree import DecisionTreeClassifier
c = DecisionTreeClassifier().fit([[1,2]], [1])
cl = c.tree_.children_left
print(cl)
del c
print(cl)
cl[0] = 1

outputs

[-1]
[-849416680]
Segmentation fault (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions