Opened 3 years ago

Closed 3 years ago

#24252 closed defect (not a bug)

undefined reference to evdns_shutdown

Reported by: maddoctor Owned by:
Priority: Medium Milestone: Tor: 0.3.2.x-final
Component: Core Tor/Tor Version: Tor: 0.3.1.9
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Using GCC 7.1.0, tor source 0.3.1.8, and libevent 2.1.8.
At the end of the building process, tor fails to link with
"undefined reference to evdns_shutdown" in libtor.a (main.c)
But -levent_extra is in the Makefile, so I can't figure out why it fails.

Child Tickets

Change History (13)

comment:1 Changed 3 years ago by nickm

Milestone: Tor: 0.3.1.x-final

comment:2 Changed 3 years ago by arma

Maybe you don't have your lib path set up correctly? Libraries need -l and sometimes also -L.

(The best answer is to install the proper libevent packages on your system, since then hopefully the right libraries will get put into the right places for the linker to find them.)

comment:3 Changed 3 years ago by maddoctor

libevent 2.1.8 is installed correctly

comment:4 Changed 3 years ago by maddoctor

Same error with 0.3.1.9 sources.
libevent is installed correctly.

comment:5 Changed 3 years ago by teor

Milestone: Tor: 0.3.1.x-finalTor: 0.3.2.x-final
Severity: BlockerNormal
Status: newneeds_information

We need some more information to help diagnose this:

What OS are you on? What distribution?
What configure command-line are you running?
What does configure say about libevent?
Is the missing function actually defined in your libevent?
What command-line is being used to link the binary that fails?

comment:6 Changed 3 years ago by maddoctor

linux, kernel 4.12.4, glibc 2.26, gcc 7.1.0

PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/share/pkgconfig \

./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc

...
checking for libevent directory... (system)
checking whether we need extra options to link libevent... (none)
checking event2/event.h usability... yes
checking event2/event.h presence... yes
checking for event2/event.h... yes
checking event2/dns.h usability... yes
checking event2/dns.h presence... yes
checking for event2/dns.h... yes
checking event2/bufferevent_ssl.h usability... yes
checking event2/bufferevent_ssl.h presence... yes
checking for event2/bufferevent_ssl.h... yes
checking for library containing event_new... -levent
checking for library containing evdns_base_new... none required
checking for evutil_secure_rng_set_urandom_device_file... yes
checking for evutil_secure_rng_add_bytes... yes
checking whether Libevent is new enough... yes
...

readelf -a /usr/lib64/libevent.so | grep dns_shutdown

392: 0000000000046050 68 FUNC LOCAL DEFAULT 11 evdns_shutdown

I do not know what command is being used to link the binary.
The Makefile is over 10000 lines long and refers back to things
like LIB and CCLD that I cannot track down.

CCLD src/or/tor

src/or/libtor.a(main.o): In function `tor_free_all':
/building/tor/tor-0.3.1.8/src/or/main.c:3211: undefined reference to `evdns_shutdown'
collect2: error: ld returned 1 exit status
make[1]: * [Makefile:4215: src/or/tor] Error 1
make[1]: Leaving directory '/building/tor/tor-0.3.1.8'
make:
* [Makefile:3106: all] Error 2

comment:7 Changed 3 years ago by maddoctor

Firefox, which is a huge project, compiled and linked against
my installed libevent, BTW

comment:8 Changed 3 years ago by teor

Please try:

make V=1

And provide the linker output for tor.

comment:9 Changed 3 years ago by maddoctor

This is with source tor-0.3.1.9:

gcc -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-all -Wstack-protector --param ssp-buffer-size=1 -fPIE -fasynchronous-unwind-tables -Wall -fno-strict-aliasing -Waddress -Warray-bounds -Wdate-time -Wdouble-promotion -Wduplicate-decl-specifier -Wduplicated-cond -Wextra -Wfloat-conversion -Wignored-attributes -Wimplicit-fallthrough -Winit-self -Wlogical-op -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wnormalized=id -Wnull-dereference -Woverlength-strings -Woverride-init -Wshadow -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wshift-overflow=2 -Wsizeof-array-argument -Wstrict-overflow=1 -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wswitch-bool -Wsync-nand -Wtrampolines -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-const-variable=2 -Wunused-local-typedefs -Wvariadic-macros -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wnested-externs -Wbad-function-cast -Wswitch-enum -Waggregate-return -Wpacked -Wunused -Wunused-parameter -Wold-style-definition -Wmissing-declarations -pie -z relro -z now -rdynamic -o src/or/tor src/or/tor_main.o src/or/libtor.a src/common/libor.a src/common/libor-ctime.a src/common/libor-crypto.a src/ext/keccak-tiny/libkeccak-tiny.a src/common/libcurve25519_donna.a src/ext/ed25519/ref10/libed25519_ref10.a src/ext/ed25519/donna/libed25519_donna.a src/common/libor-event.a src/trunnel/libor-trunnel.a src/trace/libor-trace.a -lz -lm -levent -lssl -lcrypto -L/usr/lib64 -llzma -lcap -lpthread -ldl
src/or/libtor.a(main.o): In function `tor_free_all':
/building/tor/tor-0.3.1.9/src/or/main.c:3211: undefined reference to `evdns_shutdown'
collect2: error: ld returned 1 exit status
make[1]: * [Makefile:4215: src/or/tor] Error 1
make[1]: Leaving directory '/building/tor/tor-0.3.1.9'
make:
* [Makefile:3106: all] Error 2

You see, -levent *is* there.

comment:10 Changed 3 years ago by teor

Keywords: evdns_shutdown removed
Version: Tor: 0.3.1.8Tor: 0.3.1.9

It looks like libevent isn't exporting that symbol.
Which distribution are you using, and how did you install your libevent?

The solution to this may be that Tor needs to check for that symbol at configure time, and avoid using it if it is not present.

comment:11 Changed 3 years ago by maddoctor

I don't use a distribution.

This is how I build libevent:

tar -xf libevent-release-2.1.8-stable.tar.gz
cd libevent-release-2.1.8-stable
cmake -DEVENTBUILD_SHARED_LIBRARIES=ON -DCMAKE_INSTALL_PREFIX=/usr
make
make test
make install
cd ..
rm -rf libevent-release-2.1.8-stable
strip -S build/usr/lib/*
mv build/usr/lib/libevent* /usr/lib64/

That symbol is in the library (see comment above) and in the headers
(event2/dns_compat.h).

comment:12 Changed 3 years ago by maddoctor

Did you know that libevent-2.1.8-stable.tar.gz is different from libevent-release-2.1.8-stable.tar.gz?
Nope, me neither. Anyway, problem goes away after I rebuilt libevent from the first one.

Thanks for trying to help.

comment:13 Changed 3 years ago by teor

Resolution: not a bug
Status: needs_informationclosed

This is a bug in libevent's release management (or release labelling), not a bug in tor.

Note: See TracTickets for help on using tickets.