Skip to content

Segmentation fault (random) when using xf::iselect or xf::ilocate #230

Open

Description

@jfnavarro

I have a piece of code where I try to slice a xframe object by rows and columns indexes. using 3 dynamic integer thresholds. When I try to slice with either xf::iselect or xf::ilocate I get random segmentation faults at

xt::xkeep_slice<long>::operator()(long) const

This is the code where I perform the slicing:

    const auto data_value = m_data.data().value();
    const auto row_sums = xt::sum(xt::greater(data_value, threshold1), 1);
    const auto row_indexes = xt::ravel_indices<xt::ravel_vector_tag>(
                xt::argwhere(xt::equal(row_sums > threshold_2, 1)), row_sums.shape());
    const auto col_sums = xt::sum(xt::greater(data_value, threshold_1), 0);
    const auto col_indexes = xt::ravel_indices<xt::ravel_vector_tag>(
                xt::argwhere(xt::equal(col_sums > threshold_3, 1)), col_sums.shape());
    variable_type data = xf::ilocate(m_data, xf::ikeep(row_indexes), xf::ikeep(col_indexes));

I am using the latest version of xframe (0.2.0) and xtensor (0.20.7)

Sometimes I get the segmentation fault the first time sometimes it happens the 4th or 5th time I apply the slicing.

I can provide the data frame if requested.

Activity

  1. JohanMabille commented on May 21, 2019

    @JohanMabille
    Member

    Thanks for reporting!
    I'll have a look this week, can you precise the shape of m_data and the type of labels?

  2. jfnavarro commented on May 21, 2019

    @jfnavarro
    Author

    Thanks!

    242 rows and 16251 columns.
    Types of labels is xf::fstring which I create from std::string::c_str() when parsing the input file
    The cells type is double. One could just create random labels and random values and call the slicing piece of code several times with different values for the threshold variables. The error should hopefully happen then.

    I can add that I am working on a Mac (most recent clang version).

    Here is how I create the xframe object

        using axis_type = xf::xaxis<xf::fstring>;
        using coordinate_type = xf::xcoordinate<xf::fstring>;
        using dimension_type = xf::xdimension<xf::fstring>;
        using variable_type = xf::xvariable<double, coordinate_type>;
        using data_type = variable_type::data_type;
        using shape_type = data_type::shape_type;
    
        std::vector<std::vector<double>> values;
        std::vector<xf::fstring> genes;
        std::vector<xf::fstring> spots;
        // parse file and populate vectors
    
        auto spot_axis = axis_type(spots);
        auto gene_axis = axis_type(genes);
        auto coord = coordinate_type({{"spots", spot_axis}, {"genes", gene_axis}});
        auto dim = dimension_type({"spots", "genes"});
        auto dataframe = variable_type(data, coord, dim);
    
  3. jfnavarro commented on Jun 27, 2019

    @jfnavarro
    Author

    I also noticed that xf::ilocate() seg. faults when I invoke it with only row indexes or column indexes.

    data = xf::ilocate(data, xf::ikeep(vector_idx), xf::iall());

    or

    data = xf::ilocate(data, xf::iall(), xf::ikeep(vector_idx));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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