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

*** stack smashing detected ***: terminated #2792

Open
petr-sokolov opened this issue Jun 4, 2024 · 0 comments
Open

*** stack smashing detected ***: terminated #2792

petr-sokolov opened this issue Jun 4, 2024 · 0 comments

Comments

@petr-sokolov
Copy link

petr-sokolov commented Jun 4, 2024

Hello!

I found a strange action in the code

#include <xtensor/xtensor.hpp>
#include <xtensor/xadapt.hpp>
#include <xtensor-blas/xlinalg.hpp>
#include <xtensor/xarray.hpp>
#include <xtensor/xmanipulation.hpp>
#include <iostream>

int main()
{
    // good
    {
        auto a { xt::xarray<int>::from_shape({2}) };
        std::cout << a << std::endl;
        a = xt::expand_dims(a, 0);
        std::cout << a << std::endl;
    }

    // good
    {
        auto a { xt::xtensor<float, 1>::from_shape({2}) };
        std::cout << a << std::endl;
        xt::xarray<float> b { a };
        std::cout << b << std::endl;
        b = xt::expand_dims(b, 0);
        std::cout << b << std::endl;
        xt::xtensor<float, 2> c { b };
        std::cout << c << std::endl;
    }

    // *** stack smashing detected ***: terminated
    {
        auto a { xt::xtensor<float, 1>::from_shape({2}) };
        std::cout << a << std::endl;
        a = xt::expand_dims(a, 0);
        std::cout << a << std::endl;
    }
    return 0;
}

The code returned

{1431671258,          5}
{{1431671258,          5}}
{ 1.564086e-31,  3.060436e-41}
{ 1.564086e-31,  3.060436e-41}
{{ 1.564086e-31,  3.060436e-41}}
{{ 1.564086e-31,  3.060436e-41}}
{ 1.564078e-31,  3.060436e-41}
*** stack smashing detected ***: terminated
Aborted (core dumped)

the interrupt location is near std::copy in xtl/include/xtl/xsequence.hpp

...
    /***********************************
     * forward_sequence implementation *
     ***********************************/

    namespace detail
    {
        template <class R, class A, class E = void>
        struct sequence_forwarder_impl
        {
            template <class T>
            static inline R forward(const T& r)
            {
                R ret;
                std::copy(std::begin(r), std::end(r), std::begin(ret));
                return ret;
            }
        };
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant