Skip to content

Calling lf.clear() on an empty LSHForest causes a segmentation fault down the line #76

@cwognum

Description

@cwognum

When you call clear on an empty LSHForest, it will cause a segmentation fault down the line, e.g. when trying to call layout_from_lsh_forest.

You typically wouldn't have to clear an empty tree, of course, but I had added it in a Notebook where the code cell defining the forest was separate from the code cell populating it with data. I added clear() to the second code cell to prevent myself from accidentally adding the same data twice.

Minimal Reproducible Example

import tmap as tm
import numpy as np

# Initialize a new tree
lf = tm.LSHForest(128)

# Without this line, everything will still work
lf.clear()

# Generate some mock data
data = [tm.VectorUchar(np.random.randint(0, high=2, size=128)) for _ in range(128)]

# Encode the mock data
enc = tm.Minhash(128)
fps = enc.batch_from_binary_array(data)

# Add the data to the tree
lf.batch_add(fps)
lf.index()

# This will now cause a segmentation fault
tm.layout_from_lsh_forest(lf)

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