Bug 412954 - Software tests fails after build
Summary: Software tests fails after build
Status: RESOLVED FIXED
Alias: None
Product: Heaptrack
Classification: Applications
Component: general (show other bugs)
Version: 1.1.0
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Milian Wolff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-15 04:52 UTC by systems
Modified: 2020-01-08 06:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
The complete build log (110.56 KB, text/x-log)
2019-10-15 04:52 UTC, systems
Details
Build log of master (97.23 KB, text/x-log)
2019-10-16 05:12 UTC, systems
Details

Note You need to log in before you can comment on or make changes to this bug.
Description systems 2019-10-15 04:52:28 UTC
Created attachment 123192 [details]
The complete build log

Hello,
after building, the software tests fails.
OS: CentOS 7.7

 4 - tst_inject (Failed)


4: -------------------------------------------------------------------------------
4: inject via libc
4: -------------------------------------------------------------------------------
4: /builddir/build/BUILD/heaptrack-1.1.0/tests/auto/tst_inject.cpp:105
4: ...............................................................................
4: 
4: /builddir/build/BUILD/heaptrack-1.1.0/tests/auto/tst_inject.cpp:82: FAILED:
4:   REQUIRE( contents.find("\n+") != std::string::npos )
4: with expansion:
4:   18446744073709551615 (0xffffffffffffffff)
4:   !=
4:   18446744073709551615 (0xffffffffffffffff)
4: 
4: ===============================================================================

-------------------------------------------------------------------------------
4: inject via dlopen
4: -------------------------------------------------------------------------------
4: /builddir/build/BUILD/heaptrack-1.1.0/tests/auto/tst_inject.cpp:87
4: ...............................................................................
4: 
4: /builddir/build/BUILD/heaptrack-1.1.0/tests/auto/tst_inject.cpp:82: FAILED:
4:   REQUIRE( contents.find("\n+") != std::string::npos )
4: with expansion:
4:   18446744073709551615 (0xffffffffffffffff)
4:   !=
4:   18446744073709551615 (0xffffffffffffffff)
4:
Comment 1 Milian Wolff 2019-10-15 21:09:50 UTC
can you try a newer version than 1.1 - i.e. latest git master - and see if it fails there too?
Comment 2 systems 2019-10-16 05:12:48 UTC
Created attachment 123228 [details]
Build log of master
Comment 3 systems 2019-10-16 05:13:46 UTC
The last master fails before the tests.

See the build master attachment.

/builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp:37:13: error: specialization of 'template<class _Tp> struct std::hash' in different namespace [-fpermissive]
 struct std::hash<QString> {
             ^
In file included from /usr/include/c++/4.8.2/bits/basic_string.h:3033:0,
                 from /usr/include/c++/4.8.2/string:52,
                 from /usr/include/c++/4.8.2/random:41,
                 from /usr/include/c++/4.8.2/bits/stl_algo.h:65,
                 from /usr/include/c++/4.8.2/algorithm:62,
                 from /usr/include/qt5/QtCore/qglobal.h:109,
                 from /usr/include/qt5/QtCore/qnamespace.h:43,
                 from /usr/include/qt5/QtCore/qobjectdefs.h:48,
                 from /usr/include/qt5/QtCore/qobject.h:46,
                 from /usr/include/qt5/QtCore/QObject:1,
                 from /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.h:22,
                 from /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp:19:
/usr/include/c++/4.8.2/bits/functional_hash.h:58:12: error:   from definition of 'template<class _Tp> struct std::hash' [-fpermissive]
     struct hash;
            ^
make[2]: *** [src/analyze/gui/CMakeFiles/heaptrack_gui_private.dir/parser.cpp.o] Error 1
make[2]: Leaving directory `/builddir/build/BUILD/heaptrack-master/my_build'
make[1]: *** [src/analyze/gui/CMakeFiles/heaptrack_gui_private.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Comment 4 Milian Wolff 2019-11-14 17:19:26 UTC
try again, that should be fixed by now, cf. bug 413108
Comment 5 systems 2019-11-15 11:14:28 UTC
I have tried the last master today, but the result is the same as in comment #3


cd /builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui && /usr/lib64/ccache/c++  -DKCOREADDONS_LIB -DQT_CORE_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_URL_CAST_FROM_STRING -DQT_USE_QSTRINGBUILDER -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -I/builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui -I/builddir/build/BUILD/heaptrack-master/src/analyze/gui -I/builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/include -I/builddir/build/BUILD/heaptrack-master/src -I/builddir/build/BUILD/heaptrack-master/my_build/src -I/builddir/build/BUILD/heaptrack-master/3rdparty -I/builddir/build/BUILD/heaptrack-master/my_build/src/analyze -isystem /usr/include/KF5/KI18n -isystem /usr/include/KF5 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/./mkspecs/linux-g++ -isystem /usr/include/KF5/KCoreAddons -isystem /usr/include/KF5/ThreadWeaver  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -std=c++11 -Wall -Wpedantic -std=c++0x -fno-operator-names -fno-exceptions -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Wvla -O2 -g -DNDEBUG -fvisibility=hidden -fvisibility-inlines-hidden   -Wall -fPIC -std=gnu++11 -o CMakeFiles/heaptrack_gui_private.dir/parser.cpp.o -c /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp
In file included from /builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/EWIEGA46WW/../../../../../../src/analyze/gui/parser.h:24:0,
                 from /builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/EWIEGA46WW/moc_parser.cpp:9,
                 from /builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/mocs_compilation.cpp:2:
/builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/EWIEGA46WW/../../../../../../src/analyze/gui/callercalleemodel.h: In member function 'EntryCost& CallerCalleeEntry::source(const FileLine&)':
/builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/EWIEGA46WW/../../../../../../src/analyze/gui/callercalleemodel.h:53:47: warning: missing initializer for member 'EntryCost::inclusiveCost' [-Wmissing-field-initializers]
             it = sourceMap.insert(location, {});
                                               ^
/builddir/build/BUILD/heaptrack-master/my_build/src/analyze/gui/heaptrack_gui_private_autogen/EWIEGA46WW/../../../../../../src/analyze/gui/callercalleemodel.h:53:47: warning: missing initializer for member 'EntryCost::selfCost' [-Wmissing-field-initializers]
In file included from /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.h:24:0,
                 from /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp:19:
/builddir/build/BUILD/heaptrack-master/src/analyze/gui/callercalleemodel.h: In member function 'EntryCost& CallerCalleeEntry::source(const FileLine&)':
/builddir/build/BUILD/heaptrack-master/src/analyze/gui/callercalleemodel.h:53:47: warning: missing initializer for member 'EntryCost::inclusiveCost' [-Wmissing-field-initializers]
             it = sourceMap.insert(location, {});
                                               ^
/builddir/build/BUILD/heaptrack-master/src/analyze/gui/callercalleemodel.h:53:47: warning: missing initializer for member 'EntryCost::selfCost' [-Wmissing-field-initializers]
/builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp: At global scope:
/builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp:37:13: error: specialization of 'template<class _Tp> struct std::hash' in different namespace [-fpermissive]
 struct std::hash<QString> {
             ^
In file included from /usr/include/c++/4.8.2/bits/basic_string.h:3033:0,
                 from /usr/include/c++/4.8.2/string:52,
                 from /usr/include/c++/4.8.2/random:41,
                 from /usr/include/c++/4.8.2/bits/stl_algo.h:65,
                 from /usr/include/c++/4.8.2/algorithm:62,
                 from /usr/include/qt5/QtCore/qglobal.h:109,
                 from /usr/include/qt5/QtCore/qnamespace.h:43,
                 from /usr/include/qt5/QtCore/qobjectdefs.h:48,
                 from /usr/include/qt5/QtCore/qobject.h:46,
                 from /usr/include/qt5/QtCore/QObject:1,
                 from /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.h:22,
                 from /builddir/build/BUILD/heaptrack-master/src/analyze/gui/parser.cpp:19:
/usr/include/c++/4.8.2/bits/functional_hash.h:58:12: error:   from definition of 'template<class _Tp> struct std::hash' [-fpermissive]
     struct hash;
            ^
make[2]: *** [src/analyze/gui/CMakeFiles/heaptrack_gui_private.dir/parser.cpp.o] Error 1
make[2]: Leaving directory `/builddir/build/BUILD/heaptrack-master/my_build'
make[1]: *** [src/analyze/gui/CMakeFiles/heaptrack_gui_private.dir/all] Error 2
make[1]: Leaving directory `/builddir/build/BUILD/heaptrack-master/my_build'
make: *** [all] Error 2
Comment 6 Milian Wolff 2019-12-02 16:08:17 UTC
Git commit 47692644c587518b9fc95f7310353a9c5f71cfab by Milian Wolff.
Committed on 02/12/2019 at 15:06.
Pushed by mwolff into branch 'master'.

Fix compile on CentOS 7.7

Explicitly open the std namespace to specialize std::hash.

M  +5    -2    src/analyze/gui/parser.cpp

https://commits.kde.org/heaptrack/47692644c587518b9fc95f7310353a9c5f71cfab
Comment 7 systems 2019-12-03 08:56:21 UTC
The fix will not work. The source compiles, but the test fails.
I tested it with the last master, which contains it:
5: -------------------------------------------------------------------------------
5: inject via dlopen
5: -------------------------------------------------------------------------------
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:87
5: ...............................................................................
5: 
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:82: FAILED:
5:   REQUIRE( contents.find("\n+") != std::string::npos )
5: with expansion:
5:   18446744073709551615 (0xffffffffffffffff)
5:   !=
5:   18446744073709551615 (0xffffffffffffffff)
5: 
5: -------------------------------------------------------------------------------
5: inject via libc
5: -------------------------------------------------------------------------------
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:105
5: ...............................................................................
5: 
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:82: FAILED:
5:   REQUIRE( contents.find("\n+") != std::string::npos )
5: with expansion:
5:   18446744073709551615 (0xffffffffffffffff)
5:   !=
5:   18446744073709551615 (0xffffffffffffffff)
5: 
5: ===============================================================================
5: test cases:  2 |  0 passed | 2 failed
5: assertions: 21 | 19 passed | 2 failed
5: 
2/5 Test #5: tst_inject .......................***Failed    0.02 sec
2: threads finished
Comment 8 Milian Wolff 2019-12-05 20:59:00 UTC
That's very odd - could you please change the code for the test and dump the `contents` variable to stdout?

Maybe it's some security feature in CentOS 7.7 that prevents our injector code from working? I'll have to see if I can reproduce this in a docker build of heaptrack for CentOS 7.7, but cannot promise when I get the time for that.

cheers
Comment 9 systems 2019-12-06 09:29:44 UTC
Hi, I have add this code:
const auto contents = file.readContents(); 
std::cerr << "contents is:" << contents << std::endl;
REQUIRE(!contents.empty());
...

Now I get this result:
5: Test command: /builddir/build/BUILD/heaptrack-master/my_build/tests/auto/tst_inject
5: Test timeout computed to be: 10000000
1: ===============================================================================
1: All tests passed (785 assertions in 1 test case)
1: 
2: start threads
1/5 Test #1: tst_trace ........................   Passed    0.02 sec
5: contents is:v 10250 2
5: x /builddir/build/BUILD/heaptrack-master/my_build/tests/auto/tst_inject
5: X /builddir/build/BUILD/heaptrack-master/my_build/tests/auto/tst_inject
5: I 1000 7c86ce
5: A
5: c 1
5: R 1f8
5: 
5: 
5: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5: tst_inject is a Catch v1.2.1 host application.
5: Run with -? for options
5: 
5: -------------------------------------------------------------------------------
5: inject via dlopen
5: -------------------------------------------------------------------------------
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:88
5: ...............................................................................
5: 
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:83: FAILED:
5:   REQUIRE( contents.find("\n+") != std::string::npos )
5: with expansion:
5:   18446744073709551615 (0xffffffffffffffff)
5:   !=
5:   18446744073709551615 (0xffffffffffffffff)
5: 
5: contents is:v 10250 2
5: x /builddir/build/BUILD/heaptrack-master/my_build/tests/auto/tst_inject
5: X /builddir/build/BUILD/heaptrack-master/my_build/tests/auto/tst_inject
5: I 1000 7c86ce
5: A
5: c 1
5: R 21e
5: 
5: -------------------------------------------------------------------------------
5: inject via libc
5: -------------------------------------------------------------------------------
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:106
5: ...............................................................................
5: 
5: /builddir/build/BUILD/heaptrack-master/tests/auto/tst_inject.cpp:83: FAILED:
5:   REQUIRE( contents.find("\n+") != std::string::npos )
5: with expansion:
5:   18446744073709551615 (0xffffffffffffffff)
5:   !=
5:   18446744073709551615 (0xffffffffffffffff)
5: 
5: ===============================================================================
5: test cases:  2 |  0 passed | 2 failed
5: assertions: 21 | 19 passed | 2 failed


I don't know, if this will help.
Comment 10 Milian Wolff 2019-12-06 10:50:47 UTC
it helps in showing that we do setup everything correctly, but then fail to intercept the calls to malloc etc. 

that centos machine of yours - is it using 64bit or 32bit? do you have any special devtools or other updates installed, or would it be enough for me to just download and install a centos 7.7 docker image to start digging into this?
Comment 11 Milian Wolff 2019-12-06 11:06:00 UTC
Just tried it with a centos 7.7 docker image with devtools 7 - the test works there as expected. I would say you either need to provide me with a docker image or virtual machine to reproduce this properly, or otherwise you'll have to spent some time on the heaptrack code yourself to figure out why this test is not properly working for you.
Comment 12 Milian Wolff 2019-12-06 11:06:30 UTC
FTR:
```
[root@60d1986599c5 build]# ./tests/auto/tst_inject 
===============================================================================
All tests passed (23 assertions in 2 test cases)

[root@60d1986599c5 build]# cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
[root@60d1986599c5 build]# which gcc
/opt/rh/devtoolset-7/root/usr/bin/gcc
```
Comment 13 systems 2019-12-06 11:31:22 UTC
Hi,
I use an CentOS7 64 bit VM(KVM) in which the mock tool build the software.
This are the compiler flags which are used to build it:
+ CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -I/usr/lib64/gfortran/modules'
+ export FFLAGS
+ FCFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic -I/usr/lib64/gfortran/modules'
+ export FCFLAGS
+ LDFLAGS='-Wl,-z,relro '
+ export LDFLAGS

Can some of it, responsible for it?
Comment 14 Milian Wolff 2019-12-09 20:15:03 UTC
I don't know mock, nor if the compiler flags are to be blamed. can you try without mock, and without the compiler flags?
Comment 15 systems 2020-01-06 13:43:57 UTC
Hi Milian,
mock is the tool, to build the rpm packages in an clean chroot environment, so that the result will be reproducible. It is used in the RedHat world for build the rpm package from the srpm one.

I have tested all compiler options. The "-O2" option will making this problem.
But why?
Comment 16 Milian Wolff 2020-01-07 12:06:07 UTC
Git commit 33da3a68d899facce613da1e01aed085f1dc10e8 by Milian Wolff.
Committed on 07/01/2020 at 12:04.
Pushed by mwolff into branch '1.2'.

Prevent compiler from optimizing away allocation in tst_inject

M  +1    -0    tests/CMakeLists.txt
M  +3    -0    tests/auto/tst_inject.cpp
M  +2    -5    tests/benchmarks/measure_malloc_overhead.cpp
A  +35   -0    tests/benchutil.h     [License: LGPL (v2.1+)]
M  +1    -4    tests/manual/test_linkage.c

https://commits.kde.org/heaptrack/33da3a68d899facce613da1e01aed085f1dc10e8
Comment 17 Milian Wolff 2020-01-07 12:07:04 UTC
Can you try again please?

It's quite odd, it seems as if your system compiles the test with -O2 despite the fact that it should be compiled in Debug mode (i.e. with -O0). Anyhow, the patch I pushed just now should hopefully fix it - can you check please?
Comment 18 systems 2020-01-08 06:14:08 UTC
Now, the current maser compiles on CentOS 7.7.
Thanks a lot.