google / certificate-transparency

Auditing for TLS certificates.
https://certificate.transparency.dev
Apache License 2.0
869 stars 283 forks source link

Test failed #1233

Closed ghost closed 8 years ago

ghost commented 8 years ago

I compiled CT successfully with GCC. I changed one file because it contain error (objecthash). make check-TESTS fails.

====================================================
   certificate-transparency 0.9: ./test-suite.log
====================================================

# TOTAL: 40
# PASS:  39
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: cpp/merkletree/merkle_tree_test
=====================================

[==========] Running 15 tests from 5 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from MerkleTreeFuzzTest
[ RUN      ] MerkleTreeFuzzTest.RootFuzz
[       OK ] MerkleTreeFuzzTest.RootFuzz (697 ms)
[ RUN      ] MerkleTreeFuzzTest.PathFuzz
[       OK ] MerkleTreeFuzzTest.PathFuzz (694 ms)
[ RUN      ] MerkleTreeFuzzTest.ConsistencyFuzz
[       OK ] MerkleTreeFuzzTest.ConsistencyFuzz (707 ms)
[----------] 3 tests from MerkleTreeFuzzTest (2099 ms total)

[----------] 5 tests from CompactMerkleTreeTest
[ RUN      ] CompactMerkleTreeTest.RootFuzz
[       OK ] CompactMerkleTreeTest.RootFuzz (5677 ms)
[ RUN      ] CompactMerkleTreeTest.RootTestVectors
[       OK ] CompactMerkleTreeTest.RootTestVectors (0 ms)
[ RUN      ] CompactMerkleTreeTest.TestCopyCtorWithRootTestVectors
[       OK ] CompactMerkleTreeTest.TestCopyCtorWithRootTestVectors (1 ms)
[ RUN      ] CompactMerkleTreeTest.TestCopyCtorThenAddLeafWithRootTestVectors
[       OK ] CompactMerkleTreeTest.TestCopyCtorThenAddLeafWithRootTestVectors (0 ms)
[ RUN      ] CompactMerkleTreeTest.TestCloneEmptyTreeProducesWorkingTree
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
*** Aborted at 1464612453 (unix time) try "date -d @1464612453" if you are using GNU date ***
PC: @ 0x40024cb0 ([vdso]+0xcaf)
*** SIGABRT (@0x1ca1) received by PID 7329 (TID 0x4038e600) from PID 7329; stack trace: ***
    @ 0x40024c98 ([vdso]+0xc97)
    @ 0x40024cb0 ([vdso]+0xcaf)
    @ 0x4020d607 gsignal
    @ 0x40210a33 abort
    @ 0x400e0405 __gnu_cxx::__verbose_terminate_handler()
    @ 0x400de063 (unknown)
    @ 0x400de09f std::terminate()
    @ 0x400de306 __cxa_throw
    @ 0x40135f92 std::__throw_bad_alloc()
    @ 0x800a3269 __gnu_cxx::new_allocator<>::allocate()
    @ 0x800a2ec7 std::_Vector_base<>::_M_allocate()
    @ 0x800bae3d std::_Vector_base<>::_M_create_storage()
    @ 0x800bad23 std::_Vector_base<>::_Vector_base()
    @ 0x800ba8fa std::vector<>::vector()
    @ 0x800b9853 CompactMerkleTree::CompactMerkleTree()
    @ 0x800ac297 (anonymous namespace)::CompactMerkleTreeTest_TestCloneEmptyTreeProducesWorkingTree_Test::TestBody()
    @ 0x800e4ec8 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @ 0x800dee8e testing::internal::HandleExceptionsInMethodIfSupported<>()
    @ 0x800c3f58 testing::Test::Run()
    @ 0x800c46f5 testing::TestInfo::Run()
    @ 0x800c4eb7 testing::TestCase::Run()
    @ 0x800cb576 testing::internal::UnitTestImpl::RunAllTests()
    @ 0x800e6141 testing::internal::HandleSehExceptionsInMethodIfSupported<>()
    @ 0x800dff77 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @ 0x800ca334 testing::UnitTest::Run()
    @ 0x800b353a RUN_ALL_TESTS()
    @ 0x800b0e23 main
    @ 0x401f8a83 __libc_start_main
    @ 0x800a0ff1 (unknown)
FAIL cpp/merkletree/merkle_tree_test (exit status: 134)
ghost commented 8 years ago

P. S. I compiled with some -Wno-errors and warning with sigreturn/other.

ghost commented 8 years ago

Warnings*

ghost commented 8 years ago

I fixed it by commenting lines with this code. But how to really fix it?

pphaneuf commented 8 years ago

Hmm, I believe bad_alloc happens when memory cannot be allocated. If you run cpp/merkletree/merkle_tree_test manually, you get the same error? Repeatedly?

Maybe you would get more information if you ran it under Valgrind (which should have an apt-get package for it on Ubuntu), simply like so: valgrind cpp/merkletree/merkle_tree_test

I'll give this a try with GCC today, see if I can reproduce it locally.

ghost commented 8 years ago

Valgrind — the same error, but very long tests and Valgrind message "no errors". P. S. GCC 4.8 (GCC 4.9 available), G++ 4.8 (no 4.9 in my distro packages).

pphaneuf commented 8 years ago

Hmm, couldn't reproduce it...

$ ./config.status --config
'CXXFLAGS=-O2 -ggdb -Wall -Werror -Wno-sign-compare -Wno-return-type -Wno-comment' 'evhtp_CFLAGS=-I/usr/local/google/home/pphaneuf/src/libevhtp -I/usr/local/google/home/pphaneuf/src/libevhtp/evthr -I/usr/local/google/home/pphaneuf/src/libevhtp/htparse' 'evhtp_LIBS=-L/usr/local/google/home/pphaneuf/src/libevhtp -levhtp' 'INSTALL_DIR=./install'
$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 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.

$ make V=1 cpp/merkletree/merkle_tree_test
depbase=`echo cpp/merkletree/merkle_tree_test.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
    g++ -DHAVE_CONFIG_H -I. -I./cpp  -I/usr/src/gmock/include -I/usr/src/gmock/gtest/include -Ithird_party/objecthash -I/usr/local/google/home/pphaneuf/src/libevhtp -I/usr/local/google/home/pphaneuf/src/libevhtp/evthr -I/usr/local/google/home/pphaneuf/src/libevhtp/htparse -I/usr/include/x86_64-linux-gnu   -I/usr/include/json-c   -D_FORTIFY_SOURCE=2 -fno-exceptions -O2 -ggdb -Wall -Werror -Wno-sign-compare -Wno-return-type -Wno-comment -std=gnu++11 -fstack-protector-all -fPIC -Wa,--noexecstack -Wformat -Wformat-security -MT cpp/merkletree/merkle_tree_test.o -MD -MP -MF $depbase.Tpo -c -o cpp/merkletree/merkle_tree_test.o cpp/merkletree/merkle_tree_test.cc &&\
    mv -f $depbase.Tpo $depbase.Po
sed -e "s/%BUILD_VERSION%/`git describe --abbrev=0 --dirty --always --tags`/" cpp/version.cc.in >cpp/version.cc.tmp && diff cpp/version.cc.tmp cpp/version.cc >/dev/null 2>&1 || mv -f cpp/version.cc.tmp cpp/version.cc
rm -f cpp/version.cc.tmp
g++ -fno-exceptions -O2 -ggdb -Wall -Werror -Wno-sign-compare -Wno-return-type -Wno-comment -std=gnu++11 -fstack-protector-all -fPIC -Wa,--noexecstack -Wformat -Wformat-security  -pie -o cpp/merkletree/merkle_tree_test cpp/util/util.o cpp/merkletree/merkle_tree_test.o cpp/libcore.a cpp/libtest.a -L/usr/local/google/home/pphaneuf/src/libevhtp -levhtp -levent_openssl -levent_pthreads -levent  -ltcmalloc -lssl -lcrypto -lglog -lgflags -llzma -ldl -lpthread -lresolv 
$ cpp/merkletree/merkle_tree_test
[==========] Running 15 tests from 5 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from MerkleTreeFuzzTest
[ RUN      ] MerkleTreeFuzzTest.RootFuzz
[       OK ] MerkleTreeFuzzTest.RootFuzz (170 ms)
[ RUN      ] MerkleTreeFuzzTest.PathFuzz
[       OK ] MerkleTreeFuzzTest.PathFuzz (165 ms)
[ RUN      ] MerkleTreeFuzzTest.ConsistencyFuzz
[       OK ] MerkleTreeFuzzTest.ConsistencyFuzz (166 ms)
[----------] 3 tests from MerkleTreeFuzzTest (501 ms total)

[----------] 5 tests from CompactMerkleTreeTest
[ RUN      ] CompactMerkleTreeTest.RootFuzz
[       OK ] CompactMerkleTreeTest.RootFuzz (1531 ms)
[ RUN      ] CompactMerkleTreeTest.RootTestVectors
[       OK ] CompactMerkleTreeTest.RootTestVectors (0 ms)
[ RUN      ] CompactMerkleTreeTest.TestCopyCtorWithRootTestVectors
[       OK ] CompactMerkleTreeTest.TestCopyCtorWithRootTestVectors (0 ms)
[ RUN      ] CompactMerkleTreeTest.TestCopyCtorThenAddLeafWithRootTestVectors
[       OK ] CompactMerkleTreeTest.TestCopyCtorThenAddLeafWithRootTestVectors (0 ms)
[ RUN      ] CompactMerkleTreeTest.TestCloneEmptyTreeProducesWorkingTree
[       OK ] CompactMerkleTreeTest.TestCloneEmptyTreeProducesWorkingTree (0 ms)
[----------] 5 tests from CompactMerkleTreeTest (1531 ms total)

[----------] 4 tests from MerkleTreeTest
[ RUN      ] MerkleTreeTest.RootTestVectors
[       OK ] MerkleTreeTest.RootTestVectors (0 ms)
[ RUN      ] MerkleTreeTest.PathTestVectors
[       OK ] MerkleTreeTest.PathTestVectors (0 ms)
[ RUN      ] MerkleTreeTest.ConsistencyTestVectors
[       OK ] MerkleTreeTest.ConsistencyTestVectors (0 ms)
[ RUN      ] MerkleTreeTest.AddLeafHash
[       OK ] MerkleTreeTest.AddLeafHash (0 ms)
[----------] 4 tests from MerkleTreeTest (0 ms total)

[----------] 1 test from CompactMerkleTreeFuzzTest
[ RUN      ] CompactMerkleTreeFuzzTest.CopyCtorForLargerTreesThenAppend
[       OK ] CompactMerkleTreeFuzzTest.CopyCtorForLargerTreesThenAppend (2499 ms)
[----------] 1 test from CompactMerkleTreeFuzzTest (2499 ms total)

[----------] 2 tests from MerkleVerifierTest
[ RUN      ] MerkleVerifierTest.VerifyPath
[       OK ] MerkleVerifierTest.VerifyPath (2224 ms)
[ RUN      ] MerkleVerifierTest.VerifyConsistencyProof
[       OK ] MerkleVerifierTest.VerifyConsistencyProof (1843 ms)
[----------] 2 tests from MerkleVerifierTest (4067 ms total)

[----------] Global test environment tear-down
[==========] 15 tests from 5 test cases ran. (8598 ms total)
[  PASSED  ] 15 tests.

I tried it with Valgrind, too, and it was slow, but it passed without errors.

pphaneuf commented 8 years ago

I did find a number of warnings with GCC that we do not get with Clang, hence the -Wno-sign-compare -Wno-return-type -Wno-comment I put in CXXFLAGS, we'll be fixing that.

ghost commented 8 years ago

14.04.1, not 3

ghost commented 8 years ago

Waiting for reply… :( g++ (Ubuntu 4.8.4-2ubuntu1~14.04.1)

pphaneuf commented 8 years ago

Are you running this on a system with a low amount of memory? Like a Raspberry Pi, or maybe a VPS (virtual private server)? Could you send the output of ulimit -a? It should look like this:

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256630
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 32768
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 32768
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
ghost commented 8 years ago
myuser@mypc:~$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 14592
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 14592
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
myuser@mypc:~$ 
pphaneuf commented 8 years ago

Does cpp/merkletree/merkle_tree_test --gtest_filter=CompactMerkleTreeTest.TestCloneEmptyTreeProducesWorkingTree (running only the specific test) also cause the same crash? If so could you try the following command:

strace -o foobar cpp/merkletree/merkle_tree_test --gtest_filter=CompactMerkleTreeTest.TestCloneEmptyTreeProducesWorkingTree

And attach the "foobar" file here?

ghost commented 8 years ago

The same error, no additional info, only note (filter). No additional info. ERROR: unknown command line flag 'o'

ghost commented 8 years ago

P. S. Sorry, incorrect command. Wait for strace log.

ghost commented 8 years ago

http://files.step-m.ru/files/20379/foobar.txt echo $INSTALL_DIR /home/myuser/apache2/ct_post_latest

ghost commented 8 years ago

You can see this file?

ghost commented 8 years ago

Press this link again. Waiting for reply…

ghost commented 8 years ago

CPU not supports required features (cpufreq and other feature). Close.