Skip to content

axes_objects/contourc.cpp:584: out-of-bounds while accessing the _Z_rows[n_col][n_row] in contours::is_lower_level() #77

Open
@leha-bot

Description

@leha-bot

Bug category

  • bug - compilation error
  • bug - compilation warning
  • bug - runtime error
  • bug - runtime warning
  • bug - logic error

Describe the bug
At some grids (e.g. transposed) the matplot::contourf() fails with runtime error.

Steps to Reproduce

  1. This error could be triggered by simply swapping X and Y in examples/contour_plots/contourf/contourf_1.cpp
# Your steps go here
mkdir build
cd build
cmake ..  -DCMAKE_BUILD_TYPE=Debug

Output

# The output you got
/usr/include/c++/9/bits/stl_vector.h:1042: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::vector<double>; _Alloc = std::allocator<std::vector<double> >; std::vector<_Tp, _Alloc>::reference = std::vector<double>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed.

Platform

  • cross-platform issue - linux
  • cross-platform issue - windows
  • cross-platform issue - macos

Environment Details:

  • OS: CentOS
  • OS Version: 8
  • Compiler: GCC
  • Compiler version: 9.3.1

Additional context

While debugging I found that sometimes the std::find_if() here returns end iterator and at next lines the variables n_row, n_column are could not be adjusted and this is follows to out-of-bounds error in header.
The dirty hack is the simply decrement n_row, n_col after checking all directions and before determining the opposite points here, but I doubt in robustness of this fix. @alandefreitas what do you think?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions