Skip to content

Stack use after scope error with BufferArea #22291

@vrabaud

Description

@vrabaud
System information (version)
  • OpenCV => 4.6.0
Detailed description

When running with the clang address sanitizer, the following error appears: https://github.com/google/sanitizers/wiki/AddressSanitizerUseAfterScope.

For example, if we take the resizeNN_bitexact function

area.allocate(x_ofse, dsize.width, CV_SIMD_WIDTH);
that uses a BufferArea, the BufferArea area stores a given a pointer to a pointer (x_ofse). In the BufferArea destructor, that pointer to pointer is used to reset the pointer at which is problematic because x_ofse is out of scope.

A solution could be to use a unique_ptr (but that would not work for 3.4) or call the deallocate function by hand before letting the destructor do its job. Please let me know if you see a simpler solution.

Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions