ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.06k stars 413 forks source link

Valgrind issue with Simd::Detection #116

Closed s-trinh closed 3 years ago

s-trinh commented 4 years ago

I am encountering some weird Valgrind issue with Simd::Detection.

I am using the latest code.

Details about Simd build with CMake (AVX-512 is set to off explicitely):

 Simd Library:

 Build type: 'Debug'

 Target: x86_64

 Library type: STATIC

 Toolchain: /usr/bin/c++

 Compiler ID: GNU

 Compiler Version: 5.4.0

 Performance statistic: OFF

Code used:

#include <iostream>
#include <string>

#include "Simd/SimdDetection.hpp"

int main(int argc, char * argv[])
{
    int width = 640, height = 480;
    unsigned char * bitmap = new unsigned char[width*height];
    memset(bitmap, 0, width*height);

    typedef Simd::Detection<Simd::Allocator> Detection;
    Detection detection;
    if (detection.Load("haar_face_0.xml")) {
        Detection::View image(width, height, Detection::View::Gray8, bitmap);
        detection.Init(image.Size(), 1.1, Detection::Size(30,30));

        Detection::Objects objects;
        detection.Detect(image, objects);

        for (size_t i = 0; i < objects.size(); i++) {
            std::cout << i << ") " << objects[i].rect.Left() << ", " << objects[i].rect.Top() << " ; "
                      << objects[i].rect.Width() << "x" << objects[i].rect.Height() << std::endl;
        }
    }

    delete[] bitmap;

    return 0;
}

Corresponding CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)

project(Simd-face)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Threads)

set(SRCS
    UseFaceDetection.cpp
    )

set(HEADERS
    )

include_directories(<path to>/Simd/src
    )

add_executable(UseFaceDetection ${SRCS} ${HEADERS})

target_link_libraries(UseFaceDetection ${CMAKE_THREAD_LIBS_INIT} <path to>/Simd-build/libSimd.a)
Valgrind log

``` valgrind --track-origins=yes ./UseFaceDetection ==846== Memcheck, a memory error detector ==846== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==846== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==846== Command: ./UseFaceDetection ==846== ==846== Invalid read of size 32 ==846== at 0x1B2119B: _mm256_loadu_si256 (avxintrin.h:896) ==846== by 0x1B2119B: LoadGrayIntrepolated (SimdAvx2ResizeBilinear.cpp:342) ==846== by 0x1B2119B: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:390) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Address 0x5d52d91 is 307,169 bytes inside a block of size 307,200 alloc'd ==846== at 0x4C2EB1B: operator new[](unsigned long) (vg_replace_malloc.c:423) ==846== by 0x58CE15: main (UseFaceDetection.cpp:9) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A7EB: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:74) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A7FD: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:74) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A737: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:71) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A76F: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:72) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A781: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:72) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A7AD: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:73) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A7BF: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:73) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A83B: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:77) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69A847: Simd::Base::Histogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned int*) (SimdBaseHistogram.cpp:77) ==846== by 0x69B232: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:204) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69B15C: Simd::Base::ChangeColors(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char const*, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:191) ==846== by 0x69B28D: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:209) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69B0CC: Simd::Base::ChangeColors(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char const*, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:188) ==846== by 0x69B28D: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:209) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69B0FC: Simd::Base::ChangeColors(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char const*, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:189) ==846== by 0x69B28D: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:209) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69B12C: Simd::Base::ChangeColors(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char const*, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:190) ==846== by 0x69B28D: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:209) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== Use of uninitialised value of size 8 ==846== at 0x69B198: Simd::Base::ChangeColors(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char const*, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:194) ==846== by 0x69B28D: Simd::Base::NormalizeHistogram(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long) (SimdBaseHistogram.cpp:209) ==846== by 0x5ACB42: SimdNormalizeHistogram (SimdLib.cpp:2478) ==846== by 0x5950E7: NormalizeHistogram (SimdLib.hpp:1892) ==846== by 0x5950E7: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:528) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== Uninitialised value was created by a heap allocation ==846== at 0x4C30259: memalign (vg_replace_malloc.c:898) ==846== by 0x4C30326: posix_memalign (vg_replace_malloc.c:1062) ==846== by 0x1B2039B: Allocate (SimdMemory.h:90) ==846== by 0x1B2039B: Simd::Avx2::(anonymous namespace)::BufferG::BufferG(unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:72) ==846== by 0x1B20A70: Simd::Avx2::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:357) ==846== by 0x1B21C8C: Simd::Avx2::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdAvx2ResizeBilinear.cpp:408) ==846== by 0x5B0242: SimdResizeBilinear (SimdLib.cpp:4202) ==846== by 0x594F7F: ResizeBilinear (SimdLib.hpp:2732) ==846== by 0x594F7F: Simd::Detection::FillLevels(Simd::View) (SimdDetection.hpp:526) ==846== by 0x58FC7B: Simd::Detection::Detect(Simd::View const&, std::vector::Object, std::allocator::Object> >&, int, double, bool, std::vector, std::allocator > > const&) (SimdDetection.hpp:310) ==846== by 0x58D42C: main (UseFaceDetection.cpp:19) ==846== ==846== ==846== HEAP SUMMARY: ==846== in use at exit: 0 bytes in 0 blocks ==846== total heap usage: 88,343 allocs, 88,343 frees, 83,792,038 bytes allocated ==846== ==846== All heap blocks were freed -- no leaks are possible ==846== ==846== For counts of detected and suppressed errors, rerun with: -v ==846== ERROR SUMMARY: 29 errors from 15 contexts (suppressed: 0 from 0) ```

The issue is erratic so I am not sure if the code above will reproduce the issue. This is the minimal code that reproduces the issue on my machine. Adding some code can avoid having the Valgrind issue so maybe there is a configuration issue on my machine.

s-trinh commented 4 years ago

Also, running the ./Test produces an error:

Test log

``` ./Test [140325694334784] INFO: AbsDifferenceAutoTest is started : [140325694334784] INFO: Test Simd::Base::AbsDifference & SimdAbsDifference [128, 96]. [140325694334784] INFO: Test Simd::Base::AbsDifference & SimdAbsDifference [137, 87]. [140325694334784] INFO: Test Simd::Avx2::AbsDifference & SimdAbsDifference [128, 96]. [140325694334784] INFO: Test Simd::Avx2::AbsDifference & SimdAbsDifference [137, 87]. [140325694334784] INFO: AbsDifferenceAutoTest is finished successfully. [140325694334784] INFO: AbsDifferenceSumAutoTest is started : [140325694334784] INFO: Test Simd::Base::AbsDifferenceSum & SimdAbsDifferenceSum [128, 96]. [140325694334784] INFO: Test Simd::Base::AbsDifferenceSum & SimdAbsDifferenceSum [137, 87]. [140325694334784] INFO: Test Simd::Sse2::AbsDifferenceSum & SimdAbsDifferenceSum [128, 96]. [140325694334784] INFO: Test Simd::Sse2::AbsDifferenceSum & SimdAbsDifferenceSum [137, 87]. [140325694334784] INFO: Test Simd::Avx2::AbsDifferenceSum & SimdAbsDifferenceSum [128, 96]. [140325694334784] INFO: Test Simd::Avx2::AbsDifferenceSum & SimdAbsDifferenceSum [137, 87]. [140325694334784] INFO: AbsDifferenceSumAutoTest is finished successfully. [...] [140325694334784] INFO: TexturePerformCompensationAutoTest is started : [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <17>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <3>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <0>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <-4>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <-33>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <17>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <3>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <0>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <-4>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <-33>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <17>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <3>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <0>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <-4>. [140325694334784] INFO: Test Simd::Base::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <-33>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <17>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <3>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <0>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <-4>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <-33>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <17>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <3>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <0>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <-4>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <-33>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <17>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <3>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <0>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <-4>. [140325694334784] INFO: Test Simd::Sse2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <-33>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <17>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <3>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <0>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <-4>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [128, 96] <-33>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <17>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <3>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <0>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <-4>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [137, 87] <-33>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <17>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <3>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <0>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <-4>. [140325694334784] INFO: Test Simd::Avx2::TexturePerformCompensation & SimdTexturePerformCompensation [119, 105] <-33>. [140325694334784] INFO: TexturePerformCompensationAutoTest is finished successfully. [140325694334784] INFO: TransformImageAutoTest is started : [140325694334784] INFO: Test Simd::Base::TransformImage[N0-1] & SimdTransformImage[N0-1] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-1] & SimdTransformImage[N0-1] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-2] & SimdTransformImage[N0-2] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-2] & SimdTransformImage[N0-2] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-3] & SimdTransformImage[N0-3] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-3] & SimdTransformImage[N0-3] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-4] & SimdTransformImage[N0-4] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N0-4] & SimdTransformImage[N0-4] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-1] & SimdTransformImage[N1-1] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-1] & SimdTransformImage[N1-1] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-2] & SimdTransformImage[N1-2] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-2] & SimdTransformImage[N1-2] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-3] & SimdTransformImage[N1-3] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-3] & SimdTransformImage[N1-3] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-4] & SimdTransformImage[N1-4] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N1-4] & SimdTransformImage[N1-4] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-1] & SimdTransformImage[N2-1] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-1] & SimdTransformImage[N2-1] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-2] & SimdTransformImage[N2-2] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-2] & SimdTransformImage[N2-2] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-3] & SimdTransformImage[N2-3] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-3] & SimdTransformImage[N2-3] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-4] & SimdTransformImage[N2-4] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N2-4] & SimdTransformImage[N2-4] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-1] & SimdTransformImage[N3-1] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-1] & SimdTransformImage[N3-1] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-2] & SimdTransformImage[N3-2] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-2] & SimdTransformImage[N3-2] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-3] & SimdTransformImage[N3-3] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-3] & SimdTransformImage[N3-3] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-4] & SimdTransformImage[N3-4] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[N3-4] & SimdTransformImage[N3-4] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[T0-1] & SimdTransformImage[T0-1] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[T0-1] & SimdTransformImage[T0-1] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[T0-2] & SimdTransformImage[T0-2] [128, 96]. [140325694334784] INFO: Test Simd::Base::TransformImage[T0-2] & SimdTransformImage[T0-2] [137, 87]. [140325694334784] INFO: Test Simd::Base::TransformImage[T0-3] & SimdTransformImage[T0-3] [128, 96]. [140325694334784] ERROR: Fail comparison: Error at [0,1] : (55,57,155) != (0,0,0). Error at [0,1] : (55,57,155) != (0,0,0). Error at [0,1] : (55,57,155) != (0,0,0). Error at [1,1] : (152,210,212) != (0,210,212). Error at [0,2] : (243,188,93) != (0,0,0). Error at [0,2] : (243,188,93) != (0,0,0). Error at [0,2] : (243,188,93) != (0,0,0). Error at [1,2] : (255,169,66) != (0,169,66). Error at [0,3] : (189,77,69) != (0,0,0). Error at [0,3] : (189,77,69) != (0,0,0). Error at [0,3] : (189,77,69) != (0,0,0). Error at [1,3] : (136,81,113) != (0,81,113). Error at [0,4] : (141,36,225) != (0,0,0). Error at [0,4] : (141,36,225) != (0,0,0). Error at [0,4] : (141,36,225) != (0,0,0). Error at [1,4] : (164,112,152) != (0,112,152). Error at [0,5] : (235,52,132) != (0,0,0). Error at [0,5] : (235,52,132) != (0,0,0). Error at [0,5] : (235,52,132) != (0,0,0). Error at [1,5] : (178,196,69) != (0,196,69). Error at [0,6] : (207,50,157) != (0,0,0). Error at [0,6] : (207,50,157) != (0,0,0). Error at [0,6] : (207,50,157) != (0,0,0). Error at [1,6] : (126,156,247) != (0,156,247). Error at [0,7] : (211,6,237) != (0,0,0). Error at [0,7] : (211,6,237) != (0,0,0). Error at [0,7] : (211,6,237) != (0,0,0). Error at [1,7] : (165,94,22) != (0,94,22). Error at [0,8] : (232,144,216) != (0,0,0). Error at [0,8] : (232,144,216) != (0,0,0). Error at [0,8] : (232,144,216) != (0,0,0). Error at [1,8] : (153,146,122) != (0,146,122). Stop comparison. [140325694334784] INFO: TransformImageAutoTest is finished with errors! [140325694334784] ERROR: ERROR! TEST EXECUTION IS TERMINATED ! ```

I have stripped the log to reduce the size.

Also:

ldd Test 
linux-vdso.so.1 =>  (0x00007ffe30366000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff382348000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff381fbc000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff381cb3000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff381a9b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff3816d1000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff382565000)
ermig1979 commented 4 years ago

Thank you for bug report! I will check it tomorrow.

ermig1979 commented 4 years ago

I can't reproduce the second bug in test framework (error in test of function SimdTransformImage). I used g++ 5.5.0.

ermig1979 commented 4 years ago

Also first bug is not reproduced. I used valgrind-3.13.0, g++-7.4.0, ./Test -fi=Detection -m=s

s-trinh commented 4 years ago

I tried with:

gcc --version
gcc (Ubuntu 8.3.0-16ubuntu3~16.04) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

and got the two issues.

The first issue was sporadic on my machine. I will try on another computer.

For what it worth, my machine is:

cpu

``` cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 158 model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz stepping : 10 microcode : 0xca cpu MHz : 900.033 cache size : 9216 KB physical id : 0 siblings : 6 core id : 0 cpu cores : 6 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit bogomips : 6000.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: processor : 1 vendor_id : GenuineIntel cpu family : 6 model : 158 model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz stepping : 10 microcode : 0xca cpu MHz : 900.043 cache size : 9216 KB physical id : 0 siblings : 6 core id : 1 cpu cores : 6 apicid : 2 initial apicid : 2 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit bogomips : 6000.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: processor : 2 vendor_id : GenuineIntel cpu family : 6 model : 158 model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz stepping : 10 microcode : 0xca cpu MHz : 900.057 cache size : 9216 KB physical id : 0 siblings : 6 core id : 2 cpu cores : 6 apicid : 4 initial apicid : 4 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit bogomips : 6000.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: processor : 3 vendor_id : GenuineIntel cpu family : 6 model : 158 model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz stepping : 10 microcode : 0xca cpu MHz : 900.052 cache size : 9216 KB physical id : 0 siblings : 6 core id : 3 cpu cores : 6 apicid : 6 initial apicid : 6 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit bogomips : 6000.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: processor : 4 vendor_id : GenuineIntel cpu family : 6 model : 158 model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz stepping : 10 microcode : 0xca cpu MHz : 900.042 cache size : 9216 KB physical id : 0 siblings : 6 core id : 4 cpu cores : 6 apicid : 8 initial apicid : 8 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit bogomips : 6000.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: processor : 5 vendor_id : GenuineIntel cpu family : 6 model : 158 model name : Intel(R) Core(TM) i5-8500 CPU @ 3.00GHz stepping : 10 microcode : 0xca cpu MHz : 899.697 cache size : 9216 KB physical id : 0 siblings : 6 core id : 5 cpu cores : 6 apicid : 10 initial apicid : 10 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds swapgs taa itlb_multihit bogomips : 6000.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: ```

ermig1979 commented 4 years ago

Ok. I will try to reproduce these bugs on another computer. It can require some time.

s-trinh commented 4 years ago

I have managed to somehow reproduce the issues.

See these builds:

On MacOS there is a build error:

/Users/travis/build/s-trinh/Simd/src/Simd/SimdBaseCpu.cpp:36:10: fatal error: 'sys/sysinfo.h' file not found

#include <sys/sysinfo.h>

I think #include <sys/sysinfo.h> can be removed.


On another computer without AVX2 I have:

valgrind --track-origins=yes ./UseFaceDetection 
==21711== Memcheck, a memory error detector
==21711== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==21711== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==21711== Command: ./UseFaceDetection
==21711== 
==21711== Invalid read of size 16
==21711==    at 0x11E573A: _mm_loadu_si128 (emmintrin.h:703)
==21711==    by 0x11E573A: LoadGray (SimdSsse3ResizeBilinear.cpp:317)
==21711==    by 0x11E573A: Simd::Ssse3::ResizeBilinearGray(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long) (SimdSsse3ResizeBilinear.cpp:364)
==21711==    by 0x11E6148: Simd::Ssse3::ResizeBilinear(unsigned char const*, unsigned long, unsigned long, unsigned long, unsigned char*, unsigned long, unsigned long, unsigned long, unsigned long) (SimdSsse3ResizeBilinear.cpp:386)
==21711==    by 0x584FB6: SimdResizeBilinear (SimdLib.cpp:4207)
==21711==    by 0x56A3A4: ResizeBilinear<Simd::Allocator> (SimdLib.hpp:2732)
==21711==    by 0x56A3A4: Simd::Detection<Simd::Allocator>::FillLevels(Simd::View<Simd::Allocator>) (SimdDetection.hpp:526)
==21711==    by 0x564FC2: Simd::Detection<Simd::Allocator>::Detect(Simd::View<Simd::Allocator> const&, std::vector<Simd::Detection<Simd::Allocator>::Object, std::allocator<Simd::Detection<Simd::Allocator>::Object> >&, int, double, bool, std::vector<Simd::Rectangle<long>, std::allocator<Simd::Rectangle<long> > > const&) (SimdDetection.hpp:310)
==21711==    by 0x562BCF: main (UseFaceDetection.cpp:19)
==21711==  Address 0x5da8dab is 307,195 bytes inside a block of size 307,200 alloc'd
==21711==    at 0x4C2EAEF: operator new[](unsigned long) (vg_replace_malloc.c:423)
==21711==    by 0x5625D4: main (UseFaceDetection.cpp:9)
==21711== 
==21711== 
==21711== HEAP SUMMARY:
==21711==     in use at exit: 0 bytes in 0 blocks
==21711==   total heap usage: 88,473 allocs, 88,473 frees, 83,841,126 bytes allocated
==21711== 
==21711== All heap blocks were freed -- no leaks are possible
==21711== 
==21711== For counts of detected and suppressed errors, rerun with: -v
==21711== ERROR SUMMARY: 2 errors from 1 contexts (suppressed: 0 from 0)
ermig1979 commented 4 years ago

I think #include <sys/sysinfo.h> can be removed

I agree.

Concerning to warnings of Valgrind: this is powerful tool, but sometimes it mistakes. I checked all pointed places and didn't find any error.

s-trinh commented 4 years ago

I think I have managed to reproduce my original issue. The same program can produce different detections with Simd::Detection.

Visually correct faces detection gives:

0) 198, 325 ; 43x43
1) 973, 360 ; 41x40
2) 460, 375 ; 44x44
3) 596, 435 ; 47x47
4) 708, 439 ; 46x46
5) 172, 459 ; 47x47
6) 1091, 455 ; 51x51
7) 893, 480 ; 52x51
8) 1041, 318 ; 46x46
9) 287, 352 ; 46x46
10) 1099, 358 ; 46x46
11) 674, 361 ; 43x43
12) 880, 359 ; 48x48
13) 779, 362 ; 48x48
14) 576, 381 ; 46x46
15) 54, 439 ; 48x48
16) 300, 444 ; 48x47
17) 824, 445 ; 49x49
18) 962, 447 ; 55x55
19) 98, 485 ; 47x47
20) 785, 481 ; 52x52
21) 361, 486 ; 48x48
22) 354, 379 ; 44x45
23) 440, 440 ; 53x54
24) 671, 480 ; 52x51
25) 226, 489 ; 54x53
26) 499, 488 ; 56x56
27) 1037, 487 ; 56x55
28) 1138, 505 ; 51x51
29) 35, 376 ; 79x78

and the following image:

faces_detection_ok

Visually incorrect faces detection gives:

0) 182, 325 ; 42x43
1) 957, 359 ; 42x42
2) 444, 374 ; 45x45
3) 581, 435 ; 45x46
4) 39, 439 ; 46x47
5) 692, 440 ; 45x44
6) 424, 440 ; 53x54
7) 156, 459 ; 46x46
8) 876, 479 ; 54x54
9) 1025, 318 ; 46x46
10) 273, 353 ; 44x44
11) 658, 361 ; 43x43
12) 866, 360 ; 47x47
13) 762, 362 ; 50x49
14) 338, 380 ; 44x44
15) 561, 383 ; 44x44
16) 283, 443 ; 50x49
17) 808, 446 ; 49x48
18) 947, 448 ; 53x53
19) 1075, 455 ; 51x51
20) 82, 485 ; 46x47
21) 770, 482 ; 50x50
22) 344, 485 ; 50x50
23) 482, 487 ; 57x57
24) 1023, 488 ; 52x53
25) 1083, 358 ; 47x47
26) 209, 487 ; 56x56
27) 1123, 506 ; 50x50
28) 655, 479 ; 52x53
29) 18, 376 ; 80x80

and the following image:

faces_detection_nok

Since it is erratic, I was thinking about undefined behavior or something like that, thus the valgrind check.


The issue is hardly reproducible but at least I have managed to reproduce it on Travis CI. For what it's worth, the .travis.yml script that is run on Travis, and the code. Corresponding log gives:

$ ./UseFaceDetection4
width: 1280 ; height: 926 ; channels: 
0) 182, 325 ; 42x43
1) 957, 359 ; 42x42
2) 444, 374 ; 45x45
3) 581, 435 ; 45x46
4) 39, 439 ; 46x47
5) 692, 440 ; 45x44
6) 424, 440 ; 53x54
7) 156, 459 ; 46x46
8) 876, 479 ; 54x54
9) 1025, 318 ; 46x46
10) 273, 353 ; 44x44
11) 658, 361 ; 43x43
12) 866, 360 ; 47x47
13) 762, 362 ; 50x49
14) 338, 380 ; 44x44
15) 561, 383 ; 44x44
16) 283, 443 ; 50x49
17) 808, 446 ; 49x48
18) 947, 448 ; 53x53
19) 1075, 455 ; 51x51
20) 82, 485 ; 46x47
21) 770, 482 ; 50x50
22) 344, 485 ; 50x50
23) 482, 487 ; 57x57
24) 1023, 488 ; 52x53
25) 1083, 358 ; 47x47
26) 209, 487 ; 56x56
27) 1123, 506 ; 50x50
28) 655, 479 ; 52x53
29) 18, 376 ; 80x80
The command "./UseFaceDetection4" exited with 0.

$ ./UseFaceDetection4 --input 1280px-Solvay_conference_1927.png
width: 1280 ; height: 926 ; channels: 
0) 198, 325 ; 43x43
1) 973, 360 ; 41x40
2) 460, 375 ; 44x44
3) 596, 435 ; 47x47
4) 708, 439 ; 46x46
5) 172, 459 ; 47x47
6) 1091, 455 ; 51x51
7) 893, 480 ; 52x51
8) 1041, 318 ; 46x46
9) 287, 352 ; 46x46
10) 1099, 358 ; 46x46
11) 674, 361 ; 43x43
12) 880, 359 ; 48x48
13) 779, 362 ; 48x48
14) 576, 381 ; 46x46
15) 54, 439 ; 48x48
16) 300, 444 ; 48x47
17) 824, 445 ; 49x49
18) 962, 447 ; 55x55
19) 98, 485 ; 47x47
20) 785, 481 ; 52x52
21) 361, 486 ; 48x48
22) 354, 379 ; 44x45
23) 440, 440 ; 53x54
24) 671, 480 ; 52x51
25) 226, 489 ; 54x53
26) 499, 488 ; 56x56
27) 1037, 487 ; 56x55
28) 1138, 505 ; 51x51
29) 35, 376 ; 79x78

The command "./UseFaceDetection4 --input 1280px-Solvay_conference_1927.png" exited with 0.

Input image is PNG, read with stb_image. I tried to use Google Sanitizer and different logs can be found.


Also, on ARM 32-bits, the results are different (compared to ARM 64-bits). The .drone.yml script that is launched and the corresponding log:

ARM 64-bits:

+ ./UseFaceDetection4 --input 1280px-Solvay_conference_1927.png
width: 1280 ; height: 926 ; channels: 
0) 198, 325 ; 43x43
1) 973, 360 ; 41x40
2) 460, 375 ; 44x44
3) 596, 435 ; 47x47
4) 708, 439 ; 46x46
5) 172, 459 ; 47x47
6) 1091, 455 ; 51x51
7) 893, 480 ; 52x51
8) 1041, 318 ; 46x46
9) 287, 352 ; 46x46
10) 1099, 358 ; 46x46
11) 674, 361 ; 43x43
12) 880, 359 ; 48x48
13) 779, 362 ; 48x48
14) 576, 381 ; 46x46
15) 54, 439 ; 48x48
16) 300, 444 ; 48x47
17) 824, 445 ; 49x49
18) 962, 447 ; 55x55
19) 98, 485 ; 47x47
20) 785, 481 ; 52x52
21) 361, 486 ; 48x48
22) 354, 379 ; 44x45
23) 440, 440 ; 53x54
24) 671, 480 ; 52x51
25) 226, 489 ; 54x53
26) 499, 488 ; 56x56
27) 1037, 487 ; 56x55
28) 1138, 505 ; 51x51
29) 35, 376 ; 79x78

ARM 32-bits:

+ ./UseFaceDetection4 --input 1280px-Solvay_conference_1927.png
width: 1280 ; height: 926 ; channels: 
0) 1034, 319 ; 44x44
1) 192, 326 ; 40x41
2) 282, 355 ; 41x41
3) 964, 359 ; 42x42
4) 452, 374 ; 44x45
5) 588, 436 ; 46x46
6) 700, 440 ; 45x45
7) 293, 444 ; 47x47
8) 1084, 455 ; 49x50
9) 163, 459 ; 48x47
10) 884, 480 ; 53x52
11) 353, 486 ; 47x48
12) 666, 361 ; 43x44
13) 873, 359 ; 47x48
14) 771, 362 ; 48x48
15) 46, 439 ; 48x47
16) 817, 446 ; 47x47
17) 955, 448 ; 52x52
18) 663, 480 ; 52x51
19) 90, 485 ; 47x47
20) 217, 488 ; 55x55
21) 492, 488 ; 55x55
22) 1031, 488 ; 52x52
23) 1131, 505 ; 50x51
24) 1091, 357 ; 47x48
25) 345, 379 ; 45x45
26) 569, 382 ; 44x45
27) 431, 441 ; 54x53
28) 777, 482 ; 51x51
29) 25, 376 ; 81x81

Finally, is the Simd library fully working without C++11 (i.e. C++98)?

zaidao2023 commented 1 year ago

Hello, I also seem to have found this problem, which may be caused by the image offset caused by memory alignment, which eventually leads to the wrong detection result. Is there any way to solve it?

ermig1979 commented 1 year ago

Hi! I could give answer if have more information about your issue. Best regards, Ihar.

zaidao2023 commented 1 year ago

Hi! I could give answer if have more information about your issue. Best regards, Ihar.

Hello I have found the answer from here https://github.com/ermig1979/Simd/issues/253,
the constructor I used is View(size_t w, size_t h, Format f, void * d = NULL, size_t align = Allocator::Alignment()); Now I'm using: View(size_t w, size_t h, ptrdiff_t s, Format f, void * d); solved the problem