Opened 4 years ago

Closed 3 years ago

#18841 closed defect (fixed)

Test test_bt.sh fails

Reported by: trudokal Owned by:
Priority: Medium Milestone: Tor: 0.2.7.x-final
Component: Core Tor/Tor Version: Tor: 0.2.8.2-alpha
Severity: Major Keywords: test, patch 026-backport
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

'make check' fails the test_bt.sh test. This applies to both the stable tor 0.2.7.6 and unstable tor 0.2.8.2-alpha.


For tor 0.2.7.6

% cat src/test/test_bt.sh.log
BAD
BAD
FAIL src/test/test_bt.sh (exit status: 1)

% ./test-bt-cl crash

============================================================ T= 1460898816
Tor  died: Caught signal 11
./test-bt-cl(+0x13372)[0x3364d92372]
./test-bt-cl(+0x12e90)[0x3364d91e90]
./test-bt-cl(+0x12e90)[0x3364d91e90]
./test-bt-cl(+0x12f28)[0x3364d91f28]
./test-bt-cl(+0x12fa8)[0x3364d91fa8]
./test-bt-cl(+0x13028)[0x3364d92028]
./test-bt-cl(+0x1271f)[0x3364d9171f]
/lib64/libc.so.6(__libc_start_main+0x11b)[0x36a6972582b]
./test-bt-cl(+0x12cf9)[0x3364d91cf9]

% ./test-bt-cl assert
Apr 17 15:13:40.774 [err] tor_assertion_failed_(): Bug: src/test/test_bt_cl.c:42: crash: Assertion 1 == 0 failed; aborting. (on Tor 0.2.7.6 )
Apr 17 15:13:40.774 [err] Bug: Assertion 1 == 0 failed in crash at src/test/test_bt_cl.c:42. Stack trace: (on Tor 0.2.7.6 )
Apr 17 15:13:40.774 [err] Bug:     ./test-bt-cl(+0x134a5) [0x3614e5c4a5] (on Tor 0.2.7.6 )
Apr 17 15:13:40.774 [err] Bug:     ./test-bt-cl(+0x25ccb) [0x3614e6eccb] (on Tor 0.2.7.6 )
Apr 17 15:13:40.774 [err] Bug:     ./test-bt-cl(+0x12ed7) [0x3614e5bed7] (on Tor 0.2.7.6 )
Apr 17 15:13:40.775 [err] Bug:     ./test-bt-cl(+0x12f28) [0x3614e5bf28] (on Tor 0.2.7.6 )
Apr 17 15:13:40.775 [err] Bug:     ./test-bt-cl(+0x12fa8) [0x3614e5bfa8] (on Tor 0.2.7.6 )
Apr 17 15:13:40.775 [err] Bug:     ./test-bt-cl(+0x13028) [0x3614e5c028] (on Tor 0.2.7.6 )
Apr 17 15:13:40.775 [err] Bug:     ./test-bt-cl(+0x1271f) [0x3614e5b71f] (on Tor 0.2.7.6 )
Apr 17 15:13:40.775 [err] Bug:     /lib64/libc.so.6(__libc_start_main+0x11b) [0x38a91baf82b] (on Tor 0.2.7.6 )
Apr 17 15:13:40.775 [err] Bug:     ./test-bt-cl(+0x12cf9) [0x3614e5bcf9] (on Tor 0.2.7.6 )

Similar for tor-0.2.8.2-alpha

% cat src/test/test_bt.sh.log
BAD
Apr 17 15:39:04.642 [err] tor_assertion_failed_(): Bug: src/test/test_bt_cl.c:42: crash: Assertion 1 == 0 failed; aborting. (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug: Assertion 1 == 0 failed in crash at src/test/test_bt_cl.c:42. Stack trace: (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x13b15) [0x3e56487b15] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x289db) [0x3e5649c9db] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x13547) [0x3e56487547] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x13598) [0x3e56487598] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x13618) [0x3e56487618] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x13698) [0x3e56487698] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x12d7f) [0x3e56486d7f] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     /lib64/libc.so.6(__libc_start_main+0x11b) [0x3a267d0882b] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
Apr 17 15:39:04.642 [err] Bug:     ./src/test/test-bt-cl(+0x13369) [0x3e56487369] (on Tor 0.2.8.2-alpha 684babee8491c3e9)
BAD

============================================================ T= 1460900344
Tor died: Caught signal 11
./src/test/test-bt-cl(+0x139e2)[0x50618769e2]
./src/test/test-bt-cl(+0x13500)[0x5061876500]
./src/test/test-bt-cl(+0x13500)[0x5061876500]
./src/test/test-bt-cl(+0x13598)[0x5061876598]
./src/test/test-bt-cl(+0x13618)[0x5061876618]
./src/test/test-bt-cl(+0x13698)[0x5061876698]
./src/test/test-bt-cl(+0x12d7f)[0x5061875d7f]
/lib64/libc.so.6(__libc_start_main+0x11b)[0x340da92582b]
./src/test/test-bt-cl(+0x13369)[0x5061876369]
FAIL src/test/test_bt.sh (exit status: 1)

Commands executed:

./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --disable-dependency-tracking --disable-silent-rules --libdir=/usr/lib64 --enable-system-torrc --enable-asciidoc --docdir=/usr/share/doc/tor-0.2.7.6 --disable-instrument-downloads --disable-bufferevents --disable-libscrypt --enable-seccomp --disable-systemd --enable-gcc-hardening --enable-linker-hardening --disable-transparent --disable-tor2web-mode --enable-unittests --enable-coverage
make
make check

Using gcc 4.8.5.
Reproducable: always.

Child Tickets

Attachments (1)

tor-undefine-_FORTIFY_SOURCE.patch (463 bytes) - added by trudokal 4 years ago.
Undefine _FORTIFY_SOURCE before defining it

Download all attachments as: .zip

Change History (11)

comment:1 Changed 4 years ago by nickm

Milestone: Tor: 0.2.8.x-final

comment:2 Changed 4 years ago by nickm

Hm, what kind of linux are you on? This works for me, and I can't reproduce the failure.

(Then again, I have gcc 5.3.1. I wonder if the gcc is at fault?)

Did earlier versions of Tor (containing test_bt.sh) also fail?

comment:3 Changed 4 years ago by nickm

Status: newneeds_information

comment:4 in reply to:  2 ; Changed 4 years ago by trudokal

Status: needs_informationnew

Replying to nickm:

Hm, what kind of linux are you on? This works for me, and I can't reproduce the failure.

(Then again, I have gcc 5.3.1. I wonder if the gcc is at fault?)

Did earlier versions of Tor (containing test_bt.sh) also fail?

Did some test test_bt.sh seems to have been introduced for tor-0.2.7.3-rc.
I checked versions

tor-0.2.7.3-rc
tor-0.2.7.4-rc
tor-0.2.7.6
tor-0.2.8.2-alpha

After getting a little more used to the output, I realise that the output is actually no error but intended.
What lets the test fail is that the stacktrace does not contain the 'function names', e.g. output for 'test-bt-cl crash' is

src/test/test-bt-cl(+0x15e3f)[0x7f298f879e3f]
src/test/test-bt-cl(crash+0x50)[0x7f298f879a10]
src/test/test-bt-cl(crash+0x50)[0x7f298f879a10]
src/test/test-bt-cl(oh_what+0x25)[0x7f298f879a85]
src/test/test-bt-cl(a_tangled_web+0x25)[0x7f298f879ae5]
src/test/test-bt-cl(we_weave+0x25)[0x7f298f879b55]
src/test/test-bt-cl(main+0xe9)[0x7f298f879389]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f298eb95b45]
src/test/test-bt-cl(+0x15882)[0x7f298f879882]

and not

src/test/test-bt-cl(+0x15e3f)[0x7f298f879e3f]
src/test/test-bt-cl(+0x50)[0x7f298f879a10]
src/test/test-bt-cl(+0x50)[0x7f298f879a10]
src/test/test-bt-cl(+0x25)[0x7f298f879a85]
src/test/test-bt-cl(+0x25)[0x7f298f879ae5]
src/test/test-bt-cl(+0x25)[0x7f298f879b55]
src/test/test-bt-cl(+0xe9)[0x7f298f879389]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7f298eb95b45]
src/test/test-bt-cl(+0x15882)[0x7f298f879882]

(note the missing names.)

I'm not a C/C++ programmer. But googleing reveals that passing '-rdynamic' to gcc produces those names in the stacktrace.
Indeed:

export CFLAGS="-rdynamic -g -O2"
./configure
make
make verify
[...]
PASS: src/test/test
PASS: src/test/test-slow
PASS: src/test/test-memwipe
PASS: src/test/test_workqueue
PASS: src/test/test_keygen.sh
PASS: src/test/test_zero_length_keys.sh
SKIP: src/test/test_switch_id.sh
PASS: src/test/test_ntor.sh
PASS: src/test/test_bt.sh
============================================================================
Testsuite summary for tor 0.2.9.0-alpha-dev
============================================================================
# TOTAL: 9
# PASS:  8
# SKIP:  1
# XFAIL: 0
# FAIL:  0
# XPASS: 0
# ERROR: 0
===========================================================================

Note: Above output is for the master branch, but I also tested
tor-0.2.8.2-alpha
tor-0.2.7.6
and they succeed as well.


Possible solution

Since the test depend on '-rdynamic' being set and this does not seem to be
enabled by all distributions. It should be enabled for the test.
But instead of enabling for the whole build (a distro might have a good reason
for disabling it, I don't know), only enable it in the linking phase of
test-bt-ct.

I'm not an expert in autotools/make, but getting a '-rdynamic' in the target
for test-bt-cl in Makefile.in seems to do it. Sadly, I have no clue how to get
it there, because the target is auto-generated by autogen.sh.

Changed 4 years ago by trudokal

Undefine _FORTIFY_SOURCE before defining it

comment:5 in reply to:  4 Changed 4 years ago by trudokal

Keywords: patch added
Severity: NormalMajor
Status: newneeds_review

(raised severity, because this bug misconfigures tor, see below)

Replying to trudokal:

Possible solution

Since the test depend on '-rdynamic' being set and this does not seem to be
enabled by all distributions. It should be enabled for the test.
But instead of enabling for the whole build (a distro might have a good reason
for disabling it, I don't know), only enable it in the linking phase of
test-bt-ct.

I'm not an expert in autotools/make, but getting a '-rdynamic' in the target
for test-bt-cl in Makefile.in seems to do it. Sadly, I have no clue how to get
it there, because the target is auto-generated by autogen.sh.

Investigated a little further why '-rdynamic' is not defined in CFLAGS.
config.log states

[...]
configure:9451: checking whether the linker accepts -rdynamic
configure:9494: x86_64-pc-linux-gnu-gcc -std=gnu99 -o conftest -g -O2 -D_FORTIFY_SOURCE=2 -pedantic -Werror  -I${top_srcdir}/src/common   -rdynamic conftest.c -lcap -lpthread -ldl   >&5
<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition
cc1: all warnings being treated as errors
configure:9494: $? = 1
configure: program exited with status 1
configure: failed program was:
[...]
configure:9508: result: no

Similar for a bunch of other configure checks.

The reason is that Gentoo has some patches which predefine _FORTIFY_SOURCE yielding warnings of the form

<command-line>:0:0: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>:0:0: note: this is the location of the previous definition

which in configure yield an error and hence a misconfiguration.
This warning is also printed at every file we compile.

I found a similar issue by an other software: http://tracker.ceph.com/issues/13920

The solution is simple: undefine _FORTIFY_SOURCE before defining it.

Patch

diff --git a/configure.ac b/configure.ac
index 4bdd2d3..bd50577 100644
--- a/configure.ac
+++ b/configure.ac
@@ -761,7 +761,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
 #endif])], have_clang=yes, have_clang=no)
 
 if test "x$enable_gcc_hardening" != "xno"; then
-    CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
+    CFLAGS="$CFLAGS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"
     if test "x$have_clang" = "xyes"; then
         TOR_CHECK_CFLAGS(-Qunused-arguments)
     fi

(patch is also attached)
Patch was tested against current master branch.

comment:6 Changed 4 years ago by nickm

Keywords: review-group-1 added

comment:7 Changed 4 years ago by nickm

Keywords: 026-backport added; review-group-1 removed
Milestone: Tor: 0.2.8.x-finalTor: 0.2.6.x-final

I made a branch bug18841_1_025 for this so we can backport it as far as we want. I'm adding it to 027 and forward, for possible backport to older versions.

I am also leaving this particular ticket open in case there are more reasons this happens.

comment:8 Changed 3 years ago by trudokal

Hi nickm

Just wanted to say thanks for your responsiveness and cooperation. Keep up the good work!

comment:9 Changed 3 years ago by nickm

You're welcome, and thanks for your patience and persistence with investigating this!

comment:10 Changed 3 years ago by nickm

Milestone: Tor: 0.2.6.x-finalTor: 0.2.7.x-final
Resolution: fixed
Status: needs_reviewclosed

Not planning an 0.2.6 backport; users should upgrade to 0.2.7 if they need this resolved.

Note: See TracTickets for help on using tickets.