This issue was observed when running cmake unit tests on Windows platform: in debug mode all tests were passed, in release mode it tests were failed with unknown file: error: SEH exception with code 0xc0000005 thrown in the test body.
Here is sample code to reproduce this issue:
#include <xtensor.hpp>
int main() {
xt::xarray<double> a = {0, 1, 0};
auto max = xt::argmax(a);
std::cout << max << std::endl;
return 0;
}
where cl
C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.33.31629\bin\Hostx86\x86\cl.exe
cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.33.31629 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
Thanks for reporting. I don't have easy access to Visual Studio. Would you be willing to debug this a bit? Could you tell us which part of the implementation works and which does not?
Activity
rusmozhaik commented on Aug 19, 2022
Probably it hase the same root cause: #2551
tdegeus commented on Aug 24, 2022
Thanks for reporting. I don't have easy access to Visual Studio. Would you be willing to debug this a bit? Could you tell us which part of the implementation works and which does not?
sg-james commented on Aug 30, 2022
This does have the same root at #2551.
This happens only with MSVC > v19.31
A second, minimal reproduction, found in return of argmax
It looks like there is an issue with 0 dimension xtensors / std::array<size_t, 0>.
During construction, the call to xt::resize(shape, true) fails somewhere in the inlined computed_strides()
makeshift printf stacktracext::xtensor_container<class xt::uvector<unsigned __int64,class std::allocator<unsigned __int64> >,0,1,struct xt::xtensor_expression_tag>::xtensor_container xt::shape R: class std::array<unsigned __int64,0> T: unsigned __int64 xt::detail::initializer_shape R: class std::array<unsigned __int64,0> U: unsigned __int64 size_type: unsigned __int64 xt::xtensor_container<class xt::uvector<unsigned __int64,class std::allocator<unsigned __int64> >,0,1,struct xt::xtensor_expression_tag>::xtensor_container xt::xstrided_container<class xt::xtensor_container<class xt::uvector<unsigned __int64,class std::allocator<unsigned __int64> >,0,1,struct xt::xtensor_expression_tag> >::resize D: class xt::xtensor_container<class xt::uvector<unsigned __int64,class std::allocator<unsigned __int64> >,0,1,struct xt::xtensor_expression_tag> S: class std::array<unsigned __int64,0> dim: 0 before compute_strides xt::compute_strides L: 1 shape_type: class std::array<unsigned __int64,0> layout_type: enum xt::layout_type l: 1 strides_type: class std::array<__int64,0> backstrides_type: class std::array<__int64,0> xt::detail::compute_strides L: 1 shape_type: class std::array<unsigned __int64,0> layout_type: enum xt::layout_type l: 1 strides_type: class std::array<__int64,0> bs_ptr: class std::array<__int64,0> * __ptr64 strides_value_type: __int64 data_size: 1 is_row_major size: 0I copied the relevant xtensor functions out into a minimal reproduction on godbolt.
I'm leaning towards MSVC compiler bug at this point
sg-james commented on Sep 13, 2022
upstream bug report: https://developercommunity.visualstudio.com/t/Runtime-Crash-msvc--1931-with-optimiz/10134617
tdegeus commented on Jan 6, 2023
Thanks @sg-james !! I guess would should consider adding the workaround proposed upstream for this specific compiler version?
fixes xtensor-stack#2568. Fixes MSVC optimizations causing segmentati…
sg-james commented on Jan 6, 2023
I took a stab at a PR for this. Still trying to find a place to add tests
fixes xtensor-stack#2568. Fixes MSVC optimizations causing segmentati…
fixes xtensor-stack#2568. Fixes MSVC optimizations causing segmentati…
find `argmin` using C++ STL methods
fixes xtensor-stack#2568. Fixes MSVC optimizations causing segmentati…