openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

EncodeDecodeTestAPI.SetOptionECFlag_ERROR_CON_DISABLE uses uninitialized memory

Open mstorsjo opened this issue 12 years ago • 2 comments

When running the test EncodeDecodeTestBase/EncodeDecodeTestAPI.SetOptionECFlag_ERROR_CON_DISABLE/0 within valgrind, valgrind points out that it uses uninitalized memory (doing conditional jumps based on uninitialized data).

To test, build the latest master on linux and run "valgrind ./codec_unittest --seed=0 --gtest_filter=EncodeDecodeTestBase/EncodeDecodeTestAPI.SetOptionECFlag_ERROR_CON_DISABLE/0".

On a debug build, it prints the following backtrace:

==25221== Conditional jump or move depends on uninitialised value(s)
==25221==    at 0x62314F: WelsEnc::MdInterAnalysisVaaInfo_c(int*) (md.cpp:419)
==25221==    by 0x65125B: WelsEnc::WelsMdInterFinePartitionVaa(void*, void*, WelsEnc::TagSlice*, WelsEnc::TagMB*, int) (svc_base_layer_md.cpp:1170)
==25221==    by 0x65386E: WelsEnc::WelsMdInterSecondaryModesEnc(WelsEnc::TagWelsEncCtx*, WelsEnc::TagWelsMD*, WelsEnc::TagSlice*, WelsEnc::TagMB*, WelsEnc::TagMbCache*, bool) (svc_base_layer_md.cpp:1781)
==25221==    by 0x653402: WelsEnc::WelsMdInterMb(void*, void*, WelsEnc::TagSlice*, WelsEnc::TagMB*, WelsEnc::TagMbCache*) (svc_base_layer_md.cpp:1670)
==25221==    by 0x657E5E: WelsEnc::WelsMdInterMbLoop(WelsEnc::TagWelsEncCtx*, WelsEnc::TagSlice*, void*, int) (svc_encode_slice.cpp:968)
==25221==    by 0x6571E9: WelsEnc::WelsPSliceMdEnc(WelsEnc::TagWelsEncCtx*, WelsEnc::TagSlice*, bool) (svc_encode_slice.cpp:642)
==25221==    by 0x657374: WelsEnc::WelsCodePSlice(WelsEnc::TagWelsEncCtx*, WelsEnc::TagSlice*) (svc_encode_slice.cpp:676)
==25221==    by 0x6575E1: WelsEnc::WelsCodeOneSlice(WelsEnc::TagWelsEncCtx*, int, int) (svc_encode_slice.cpp:748)
==25221==    by 0x642878: WelsEnc::WelsEncoderEncodeExt(WelsEnc::TagWelsEncCtx*, SFrameBSInfo*, Source_Picture_s const*) (encoder_ext.cpp:3371)
==25221==    by 0x635626: WelsEnc::CWelsH264SVCEncoder::EncodeFrameInternal(Source_Picture_s const*, SFrameBSInfo*) (welsEncoderExt.cpp:414)
==25221==    by 0x6355E4: WelsEnc::CWelsH264SVCEncoder::EncodeFrame(Source_Picture_s const*, SFrameBSInfo*) (welsEncoderExt.cpp:395)
==25221==    by 0x5B6D37: EncodeDecodeTestAPI_SetOptionECFlag_ERROR_CON_DISABLE_Test::TestBody() (encode_decode_api_test.cpp:643)
==25221== 

(Currently there's also a few other warnings pointed out by valgrind, that are fixed by #1360 and #1361.)

It seems that after the first call to ENCODER_LTR_RECOVERY_REQUEST, it still encodes a P frame, but the SAD used for mode decision is based on an uninitialized reference frame.

mstorsjo avatar Sep 16 '14 09:09 mstorsjo

discussion here: https://rbcommons.com/s/OpenH264/r/1044/

sijchen avatar Jan 07 '15 05:01 sijchen

This has been fixed now.

mstorsjo avatar Jan 13 '15 09:01 mstorsjo