Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
jfnavarro opened this issue May 21, 2019 · 3 comments
Open

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

jfnavarro opened this issue May 21, 2019 · 3 comments
Labels

Comments

@jfnavarro
Copy link

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.

@JohanMabille
Copy link
Member

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

@jfnavarro
Copy link
Author

jfnavarro commented May 21, 2019

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);

@jfnavarro
Copy link
Author

jfnavarro commented Jun 27, 2019

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants