Skip to content

fix for png durations and memory leak#26714

Merged
asmorkalov merged 4 commits intoopencv:4.xfrom
sturkmen72:png
Jan 6, 2025
Merged

fix for png durations and memory leak#26714
asmorkalov merged 4 commits intoopencv:4.xfrom
sturkmen72:png

Conversation

@sturkmen72
Copy link
Copy Markdown
Contributor

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 original 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

@opencv-alalek opencv-alalek added this to the 4.11.0 milestone Jan 5, 2025
@asmorkalov
Copy link
Copy Markdown
Contributor

The patch totally makes sense. It reduces memory leaks significantly, but I still observe a case:

Direct leak of 490 byte(s) in 6 object(s) allocated from:
    #0 0x71ff4b4fe548 in operator new(unsigned long) ../../../../src/libsanitizer/asan/asan_new_delete.cpp:95
    #1 0x58bfb3ea544f in std::__new_allocator<unsigned char>::allocate(unsigned long, void const*) /usr/include/c++/13/bits/new_allocator.h:151
    #2 0x58bfb3ea1c8e in std::allocator_traits<std::allocator<unsigned char> >::allocate(std::allocator<unsigned char>&, unsigned long) /usr/include/c++/13/bits/alloc_traits.h:482
    #3 0x58bfb3ea1c8e in std::_Vector_base<unsigned char, std::allocator<unsigned char> >::_M_allocate(unsigned long) /usr/include/c++/13/bits/stl_vector.h:381
    #4 0x58bfb3e9f008 in std::vector<unsigned char, std::allocator<unsigned char> >::_M_default_append(unsigned long) /usr/include/c++/13/bits/vector.tcc:663
    #5 0x71ff4ac9f962 in std::vector<unsigned char, std::allocator<unsigned char> >::resize(unsigned long) /usr/include/c++/13/bits/stl_vector.h:1016
    #6 0x71ff4ad39e13 in cv::PngDecoder::read_chunk(cv::Chunk&) /mnt/Projects/Projects/opencv/modules/imgcodecs/src/grfmt_png.cpp:730
    #7 0x71ff4ad31a96 in cv::PngDecoder::readHeader() /mnt/Projects/Projects/opencv/modules/imgcodecs/src/grfmt_png.cpp:293
    #8 0x71ff4ac8078c in imread_ /mnt/Projects/Projects/opencv/modules/imgcodecs/src/loadsave.cpp:461
    #9 0x71ff4ac838c0 in cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) /mnt/Projects/Projects/opencv/modules/imgcodecs/src/loadsave.cpp:657
    #10 0x58bfb3faa564 in Body /mnt/Projects/Projects/opencv/modules/imgcodecs/test/test_png.cpp:304
    #11 0x58bfb3fa9ee4 in TestBody /mnt/Projects/Projects/opencv/modules/imgcodecs/test/test_png.cpp:299
    #12 0x58bfb419c802 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3919
    #13 0x58bfb418da15 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3955
    #14 0x58bfb4139035 in testing::Test::Run() /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3993
    #15 0x58bfb413a504 in testing::TestInfo::Run() /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:4169
    #16 0x58bfb413b1a5 in testing::TestCase::Run() /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:4287
    #17 0x58bfb415675b in testing::internal::UnitTestImpl::RunAllTests() /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:6662
    #18 0x58bfb419fbaa in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3919
    #19 0x58bfb4190056 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:3955
    #20 0x58bfb4153413 in testing::UnitTest::Run() /mnt/Projects/Projects/opencv/modules/ts/src/ts_gtest.cpp:6271
    #21 0x58bfb3f9c0c3 in RUN_ALL_TESTS() /mnt/Projects/Projects/opencv/modules/ts/include/opencv2/ts/ts_gtest.h:22240
    #22 0x58bfb3f9961b in main /mnt/Projects/Projects/opencv/modules/imgcodecs/test/test_main.cpp:10
    #23 0x71ff4582a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #24 0x71ff4582a28a in __libc_start_main_impl ../csu/libc-start.c:360
    #25 0x58bfb3e6ad34 in _start (/mnt/Projects/Projects/opencv-build-debug/bin/opencv_test_imgcodecs+0x9fd34) (BuildId: fab86b1e6632766a9816aa23160ac07fb6dadd77)

It's together with my fix. Looking on it right now.

@asmorkalov asmorkalov changed the title fix for png durations fix for png durations and memory leak Jan 6, 2025
@asmorkalov asmorkalov merged commit 2aee947 into opencv:4.x Jan 6, 2025
@asmorkalov
Copy link
Copy Markdown
Contributor

Looks like the issue above is false alarm. Will recheck one thing and raise a PR, in case of issue.

@sturkmen72 sturkmen72 deleted the png branch January 6, 2025 12:56
@asmorkalov asmorkalov mentioned this pull request Jan 15, 2025
shyama7004 pushed a commit to shyama7004/opencv that referenced this pull request Jan 20, 2025
Fix for png durations and memory leak opencv#26714

### Pull Request Readiness Checklist

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

- [x] I agree to contribute to the project under Apache 2 License.
- [x] 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 original 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
NanQin555 pushed a commit to NanQin555/opencv that referenced this pull request Feb 24, 2025
Fix for png durations and memory leak opencv#26714

### Pull Request Readiness Checklist

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

- [x] I agree to contribute to the project under Apache 2 License.
- [x] 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 original 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
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.

4 participants