fraunhoferhhi / vvdec

VVdeC, the Fraunhofer Versatile Video Decoder
https://www.hhi.fraunhofer.de/en/departments/vca/technologies-and-solutions/h266-vvc.html
BSD 3-Clause Clear License
467 stars 99 forks source link

Uninitialized Variables in ARM7l Build #216

Open Xosrov opened 4 days ago

Xosrov commented 4 days ago

I'm testing on a armv7l (32bit) system within docker to build vvdec, here is the output of uname -a:
Linux d9f643bbff1e 6.8.0-49-generic #49-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 4 02:06:24 UTC 2024 armv7l armv7l armv7l GNU/Linux

The release build fails because of uninitialized variables. Ignoring these errors does cause segfaults when decoding some VVC samples. I'm using the latest release v3.0.0.

In file included from /app/vvdec/source/Lib/CommonLib/x86/sse41/IntraPred_sse41.cpp:43:
/app/vvdec/source/Lib/CommonLib/x86/sse41/../IntraPredX86.h: In function ‘void vvdec::IntraPredAngleCore_SIMD(int16_t*, ptrdiff_t, int16_t*, int, int, int, int, const TFilterCoeff*, bool, const ClpRng&) [with vvdec::x86_simd::X86_VEXT vext = vvdec::x86_simd::SSE41; int W = 8]’:
/app/vvdec/source/Lib/CommonLib/x86/sse41/../IntraPredX86.h:309:22: error: ‘vbdmax’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  309 |       __m128i vbdmin,vbdmax;
      |                      ^~~~~~

Let me know if you need assistance setting up the build environment. Thank you!

adamjw24 commented 4 days ago

The variables are initialized alright, your compiler is over-sensitive.

Please try compiling setting either enable-werror=0 for make or -DVVDEC_ENABLE_WERROR=0.

Would be great if you could share the bitstream, so we can see where the segfailts are actually coming form.

adamjw24 commented 4 days ago

There might also be an issue with the armv7, which is causing the issues. We'll investigate it a bit.

K-os commented 3 days ago

Which compiler are you using? That is more interesting than your kernel.

I created a PR, that fixes at least cross-compilation for armv7 for me. I don't have an armv7 machine here to test native compilation or the resulting binary.

The -Wmaybe-uninitialized warning was an artifact of a missing -mfpu=neon flag.

Can you please test if that fixes your issues?

Xosrov commented 3 days ago

Hi again, sorry for the late reply. The build problem was solved. I was cross compiling for the armv7l platform from another docker image, and using the cmake toolchain worked for me:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="../cmake/toolchains/arm-linux-gnueabihf-gcc-ubuntu.cmake" ..

The sample is here (wouldn't let me upload it here). I am using another piece of code that integrates vvdec (v2.3.0) and running valgrind with it. During decode, it crashes with a bus error, and running with Valgrind I see:

==135401== Conditional jump or move depends on uninitialised value(s)
==135401==    at 0xB0E90AC: void vvdec::fastInv_SSE<(vvdec::x86_simd::X86_VEXT)1, 16>(short const*, int const*, int*, unsigned int, unsigned int, unsigned int) (TrafoX86.h:217)
==135401==    by 0xB0AF6D7: _fastInverseMM<16> (TrQuant_EMT.cpp:111)
==135401==    by 0xB0AF6D7: vvdec::fastInverseDST7_B16(int const*, int*, int, int, int, int, bool, int, int) (TrQuant_EMT.cpp:325)
==135401==    by 0xB0AD94F: vvdec::TrQuant::xIT(vvdec::TransformUnit const&, vvdec::ComponentID const&, vvdec::AreaBuf<int const> const&, vvdec::AreaBuf<short>&) (TrQuant.cpp:479)
==135401==    by 0xB0AE127: vvdec::TrQuant::invTransformNxN(vvdec::TransformUnit&, vvdec::ComponentID const&, vvdec::AreaBuf<short>&, vvdec::QpParam const&) (TrQuant.cpp:314)
==135401==    by 0xB0C6D13: reconstructResi (DecCu.cpp:575)
==135401==    by 0xB0C6D13: vvdec::DecCu::TaskTrafoCtu(vvdec::CodingStructure&, int, vvdec::UnitArea const&) (DecCu.cpp:116)
==135401==    by 0xB034D47: bool vvdec::DecLibRecon::ctuTask<false>(int, vvdec::CtuTaskParam*) (DecLibRecon.cpp:836)
==135401==    by 0xB07A7FF: processTask (ThreadPool.cpp:347)
==135401==    by 0xB07A7FF: vvdec::ThreadPool::threadProc(int) (ThreadPool.cpp:266)
==135401==    by 0x4F40225: ??? (in /usr/lib/arm-linux-gnueabihf/libstdc++.so.6.0.30)
==135401== 

vvdecapp doesn't crash, but running it with Valgrind does produce some errors (this time the v3.0.0 release build was used):

==186218== Memcheck, a memory error detector
==186218== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==186218== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==186218== Command: ./vvdecapp -v 5 -b ../../../Traffic_1920x1080.h266
==186218== 
==186218== error calling PR_SET_PTRACER, vgdb might block
VVdeC, the Fraunhofer VVC/H.266 decoder, version 3.0.0 [THREADS=20; PARSE_DELAY=20; SIMD=NEON/SIMDE(SSE41)]
vvdecapp [verbose]: more data needed to tune in
...
POC    0 LId:  0 TId: 0 ( I-SLICE, QP 22 ) [DT 39.031] [L0 ] [L1 ] 
vvdecapp [verbose]: more data needed to tune in
==186218== Thread 14 DecThread12:
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x135F28: vvdec::AreaBuf<short>::fill(short const&) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A6740: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A6756: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A67E8: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A6810: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Use of uninitialised value of size 4
==186218==    at 0x1A6E6A: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A6E88: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A6C76: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A676C: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Use of uninitialised value of size 4
==186218==    at 0x1A678C: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Conditional jump or move depends on uninitialised value(s)
==186218==    at 0x1A67C2: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Use of uninitialised value of size 4
==186218==    at 0x1A67B0: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 
==186218== Use of uninitialised value of size 4
==186218==    at 0x1A67B8: vvdec::IntraPrediction::predIntraChromaLM(vvdec::ComponentID, vvdec::AreaBuf<short>&, vvdec::CodingUnit const&, vvdec::CompArea const&, int) (in /app/cinemo/vvdec/bin/release-static/vvdecapp)
==186218== 

The actual valgrind output from vvdecapp is a lot larger, but it's repeating basically the same stuff. Valgrind reports no issues on amd64