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

Running the convolve_2d.cpp test causes an alignment error on ARM #734

Open
dkrejsa opened this issue May 8, 2023 · 0 comments
Open

Running the convolve_2d.cpp test causes an alignment error on ARM #734

dkrejsa opened this issue May 8, 2023 · 0 comments

Comments

@dkrejsa
Copy link

dkrejsa commented May 8, 2023

Actual behavior

When running the convolve_2d.cpp test module (Boost 1.81.0) on a 32-bit ARM target, there is an alignment
exception (fault) in the test_convolve_2d_with_image_using_float32_t() test case. The alignment exception
occurs when the convolve_2d_impl() function attempts to access the first pixel in the second row of
the src_view. The address computed for src_view(col_boundary, row_boundary)[0] is not a multiple of
the size of the gil::float32_t array element.

The apparent cause is that the test case creates the gil::interleaved_view() calls for the source and output
images use the number of columns in the row rather than the length in bytes of each row as the
last argument to gill::interleaved_view(). Likely

gil::gray32fc_view_t src_view =
        gil::interleaved_view(9, 9, reinterpret_cast<gil::gray32f_pixel_t const*>(img), 9);
gil::gray32fc_view_t exp_out_view =
        gil::interleaved_view(9, 9, reinterpret_cast<gil::gray32f_pixel_t const*>(exp_output), 9);

should be

gil::gray32fc_view_t src_view =
        gil::interleaved_view(9, 9, reinterpret_cast<gil::gray32f_pixel_t const*>(img), 9 * sizeof (gil::float32_t));
gil::gray32fc_view_t exp_out_view =
        gil::interleaved_view(9, 9, reinterpret_cast<gil::gray32f_pixel_t const*>(exp_output), 9 * sizeof (gil::float32_t));

Expected behavior

The test should not cause an alignment exception and should complete successfully.

C++ Minimal Working Example

Use the convolve_2d.cpp test case on a target that gives exceptions for misaligned accesses.

Environment

  • Compiler version:
  • Build settings:
  • Version (Git ref or <boost/version.hpp>):
@dkrejsa dkrejsa changed the title Running the convolve_2d.cpp test causes an alighment error on ARM Running the convolve_2d.cpp test causes an alignment error on ARM May 8, 2023
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