xtensor
xtensor copied to clipboard
*** stack smashing detected ***: terminated
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;
}
};
....