FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

argmax crashes when compiled using Visual Studio compiler with O1/O2 optimizations · Issue #2568 · xtensor-stack/xtensor · GitHub

Repository navigation

argmax crashes when compiled using Visual Studio compiler with O1/O2 optimizations #2568

Closed

Description

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

cl /I xtensor-0.24.2\include /I xtl-0.7.4\include argmax.cpp produces exe which doesn't crash

cl /I xtensor-0.24.2\include /I xtl-0.7.4\include /O1 argmax.cpp produces exe which crashes

Compiler information:

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... ]

Activity

  1. rusmozhaik commented on Aug 19, 2022

    Author

    Probably it hase the same root cause: #2551

  2. tdegeus commented on Aug 24, 2022

    Member

    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?

  3. sg-james commented on Aug 30, 2022

    Contributor

    This does have the same root at #2551.

    This happens only with MSVC > v19.31

    A second, minimal reproduction, found in return of argmax

    #include <xtensor.hpp>
    
    int main() {
        xt::xtensor<std::size_t, 0> a{5};
        return 0;
    }

    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 stacktrace
    xt::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: 0
    

    I copied the relevant xtensor functions out into a minimal reproduction on godbolt.

    I'm leaning towards MSVC compiler bug at this point

  4. sg-james commented on Sep 13, 2022

    Contributor
  5. tdegeus commented on Jan 6, 2023

    Member

    Thanks @sg-james !! I guess would should consider adding the workaround proposed upstream for this specific compiler version?

  6. added a commit that references this issue on Jan 6, 2023
    780a8ed
  7. sg-james commented on Jan 6, 2023

    Contributor

    I took a stab at a PR for this. Still trying to find a place to add tests

  8. added 2 commits that reference this issue on Jan 6, 2023
    24f9a89
    7e9029c
  9. added a commit that references this issue on Feb 22, 2024
    288072a
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL