intel / libyami

Yet Another Media Infrastructure. it is core part of media codec with hardware acceleration, it is yummy to your video experience on Linux like platform.
Apache License 2.0
147 stars 106 forks source link

Integer overflow for 32bit build in gtest #833

Open kwizart opened 6 years ago

kwizart commented 6 years ago

Building current git on fedora 27 i686 and armv7hl with gtest fails with:


g++ -DHAVE_CONFIG_H -I. -I.. -I../interface -I../gtestsrc/gtest/include -g -O2 -Wall -Wno-unused-function -Wno-cpp -Wno-missing-braces -Werror -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m32 -march=i686 -mtune=generic -fasynchronous-unwind-tables -c -o unittest-utils_unittest.o test -f 'utils_unittest.cpp' || echo './'utils_unittest.cpp make[2]: Leaving directory '/builddir/build/BUILD/libyami-40fa32e79f12c3c85c360532be00b7e4f9a35920/common' utils_unittest.cpp: In member function 'virtual void UtilsTest_guessResolutionOverflow_Test::TestBody()': utils_unittest.cpp:134:54: error: integer overflow in expression [-Werror=overflow] sstream << long(std::numeric_limits::max()) * 2 + 3


utils_unittest.cpp:136:54: error: integer overflow in expression [-Werror=overflow]
             << long(std::numeric_limits<int>::max()) * 3 + 2;
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cc1plus: all warnings being treated as errors
xuguangxin commented 6 years ago

@kwizart , thanks for reporting this, @wangzj0601 , could you help to check?

xuguangxin commented 6 years ago

@wangzj0601 ,any update on this?

wangzj0601 commented 6 years ago

@xuguangxin, I am building the environment now.

uartie commented 6 years ago

OK, long and int are the same size on 32-bit compiler... thus, coercing the type to long long to clear the error and get the test to compile is not enough. The test will still fail when executed... and clearly it exposes another underlying flaw in the guessResolution function.

FYI, there are many more compiler errors on 32-bit builds beyond this (try enabling all encoders, decoders and debug and you'll see). Clearly, no one had 32-bit support in mind when developing this library.