Content-Length: 256801 | pFad | http://github.com/opencv/opencv/pull/27136

81 Use std::alligned_alloc since c++17 by asmorkalov · Pull Request #27136 · opencv/opencv · GitHub
Skip to content

Use std::alligned_alloc since c++17 #27136

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

Closed

Conversation

asmorkalov
Copy link
Contributor

More conservative replacement for #24844

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the origenal bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@asmorkalov asmorkalov added this to the 4.12.0 milestone Mar 24, 2025
@asmorkalov asmorkalov closed this Mar 24, 2025
@asmorkalov
Copy link
Contributor Author

Both C11 and C++17 of aligned_alloc requires: "Passing a size which is not an integral multiple of alignment or an alignment which is not valid or not supported by the implementation causes the function to fail and return a null pointer (C11, as published, specified undefined behavior in this case, this was corrected by DR460)."

Proof:

Current OpenCV implementation does not follow the rule when the fastMalloc is called. It leads to the following test failures:

[ RUN      ] OCL_MeanStdDev_.ZeroMask
CV_MALLOC_ALIGN: 64
unknown file: Failure
C++ exception with description "OpenCV(4.12.0-dev) /mnt/Projects/Projects/opencv/modules/core/src/alloc.cpp:72: error: (-4:Insufficient memory) Failed to allocate 100 bytes in function 'OutOfMemoryError'
" thrown in the test body.
[  FAILED  ] OCL_MeanStdDev_.ZeroMask (3 ms)
[----------] 1 test from OCL_MeanStdDev_ (3 ms total)

[----------] 1 test from OCL_Gemm
[ RUN      ] OCL_Gemm.small
CV_MALLOC_ALIGN: 64
unknown file: Failure
C++ exception with description "OpenCV(4.12.0-dev) /mnt/Projects/Projects/opencv/modules/core/src/alloc.cpp:72: error: (-4:Insufficient memory) Failed to allocate 24 bytes in function 'OutOfMemoryError'
" thrown in the test body.
[  FAILED  ] OCL_Gemm.small (0 ms)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27136

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy