PowerDNS / weakforced

Anti-Abuse for servers at authentication time
GNU General Public License v3.0
124 stars 33 forks source link

[BUG] linking fails with undefined symbol 'pthread_rwlock_unlock' #344

Closed slavkoja closed 2 years ago

slavkoja commented 3 years ago

Describe the bug I tried to build weakforced package for debian testing (bullseye) and it fails to link final wforce binary. The linking fails with:

/bin/bash ../libtool  --tag=CXX   --mode=link g++  -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security   -Wl,-z,relro -o wf_dump_entries dump_entries.o /build/weakforced-2.4.1/common/libweakforce.la -lcurl -lsodium 
libtool: link: g++ -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o wf_dump_entries dump_entries.o  /build/weakforced-2.4.1/common/.libs/libweakforce.a -L/build/weakforced-2.4.1/ext/yahttp/yahttp -L/build/weakforced-2.4.1/ext/json11 -lboost_filesystem -lboost_system -lmaxminddb -lprometheus-cpp-core -lcurl -lsodium
/bin/bash ../libtool  --tag=CXX   --mode=link g++  -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security   -Wl,-z,relro -o wforce wforce.o wforce-lua.o wforce-web.o wforce-sibling.o twmap.o twmap-wrapper.o blackwhitelist.o replication.o replication_sdb.o replication_bl.o replication_wl.o wforce-replication.o wforce-prometheus.o replication.pb.o -lreadline -lluajit-5.1 -L/build/weakforced-2.4.1/ext/yahttp/yahttp -lyahttp /build/weakforced-2.4.1/ext/ext/libext.la /build/weakforced-2.4.1/common/libweakforce.la -lsodium  -lmaxminddb -lgetdns  -lprotobuf -lsystemd -L/build/weakforced-2.4.1/ext/json11 -ljson11 -lboost_date_time -lboost_regex -lhiredis -lcurl  -lcrypto -lyaml-cpp -L/usr/lib -lprometheus-cpp-core 
libtool: link: g++ -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o wforce wforce.o wforce-lua.o wforce-web.o wforce-sibling.o twmap.o twmap-wrapper.o blackwhitelist.o replication.o replication_sdb.o replication_bl.o replication_wl.o wforce-replication.o wforce-prometheus.o replication.pb.o  -lreadline -lluajit-5.1 -L/build/weakforced-2.4.1/ext/yahttp/yahttp /build/weakforced-2.4.1/ext/yahttp/yahttp/.libs/libyahttp.a /build/weakforced-2.4.1/ext/ext/.libs/libext.a /build/weakforced-2.4.1/common/.libs/libweakforce.a -L/build/weakforced-2.4.1/ext/json11 -lboost_filesystem -lboost_system -lsodium -lmaxminddb -lgetdns -lprotobuf -lsystemd /build/weakforced-2.4.1/ext/json11/.libs/libjson11.a -lboost_date_time -lboost_regex -lhiredis -lcurl -lcrypto -lyaml-cpp -L/usr/lib -lprometheus-cpp-core
/usr/bin/ld: blackwhitelist.o: undefined reference to symbol 'pthread_rwlock_unlock@@GLIBC_2.2.5'
/usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

For now i do not know if it is my package mistake or something other.

To Reproduce My package files are base on debian's files in builder-support directory, with some changes as they seems to be outdated. I use these build dependencies:

debhelper-compat (= 13),
 libboost-all-dev (>= 1.40),
 libgetdns-dev,
 libmaxminddb-dev,
 libsodium-dev,
 libsystemd-dev,
 libhiredis-dev,
 libcurl4-openssl-dev,
 libluajit-5.1-dev,
 libyaml-cpp-dev,
 libreadline-dev,
 libprotobuf-dev,
 libssl-dev,
 libc6-dev,
 prometheus-cpp-dev,
 pkg-config,
 protobuf-compiler,
 pandoc

For build instructions i use:

%:
        dh $@

override_dh_auto_configure:
        dh_auto_configure -- \
                --with-luajit \
                --sysconfdir=/etc/wforce \
                --enable-trackalert

I patched Makefile to not use wget to get regexes.yaml as network access has troubles in build time. And i use debian's pbuilder to build in fresh system chroot every time.

Expected behavior I will expect, that linking will be success.

OS (please complete the following information):

neilcook commented 3 years ago

Looks like you’re missing libpthread as an explicit dependency,

Neil

On 19 Jul 2021, at 11:17, Slavko @.***> wrote:

Describe the bug I tried to build weakforced package for debian testing (bullseye) and it fails to link final wforce binary. The linking fails with:

/bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -o wf_dump_entries dump_entries.o /build/weakforced-2.4.1/common/libweakforce.la -lcurl -lsodium libtool: link: g++ -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o wf_dump_entries dump_entries.o /build/weakforced-2.4.1/common/.libs/libweakforce.a -L/build/weakforced-2.4.1/ext/yahttp/yahttp -L/build/weakforced-2.4.1/ext/json11 -lboost_filesystem -lboost_system -lmaxminddb -lprometheus-cpp-core -lcurl -lsodium /bin/bash ../libtool --tag=CXX --mode=link g++ -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -o wforce wforce.o wforce-lua.o wforce-web.o wforce-sibling.o twmap.o twmap-wrapper.o blackwhitelist.o replication.o replication_sdb.o replication_bl.o replication_wl.o wforce-replication.o wforce-prometheus.o replication.pb.o -lreadline -lluajit-5.1 -L/build/weakforced-2.4.1/ext/yahttp/yahttp -lyahttp /build/weakforced-2.4.1/ext/ext/libext.la /build/weakforced-2.4.1/common/libweakforce.la -lsodium -lmaxminddb -lgetdns -lprotobuf -lsystemd -L/build/weakforced-2.4.1/ext/json11 -ljson11 -lboost_date_time -lboost_regex -lhiredis -lcurl -lcrypto -lyaml-cpp -L/usr/lib -lprometheus-cpp-core libtool: link: g++ -g -O2 -ffile-prefix-map=/build/weakforced-2.4.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,relro -o wforce wforce.o wforce-lua.o wforce-web.o wforce-sibling.o twmap.o twmap-wrapper.o blackwhitelist.o replication.o replication_sdb.o replication_bl.o replication_wl.o wforce-replication.o wforce-prometheus.o replication.pb.o -lreadline -lluajit-5.1 -L/build/weakforced-2.4.1/ext/yahttp/yahttp /build/weakforced-2.4.1/ext/yahttp/yahttp/.libs/libyahttp.a /build/weakforced-2.4.1/ext/ext/.libs/libext.a /build/weakforced-2.4.1/common/.libs/libweakforce.a -L/build/weakforced-2.4.1/ext/json11 -lboost_filesystem -lboost_system -lsodium -lmaxminddb -lgetdns -lprotobuf -lsystemd /build/weakforced-2.4.1/ext/json11/.libs/libjson11.a -lboost_date_time -lboost_regex -lhiredis -lcurl -lcrypto -lyaml-cpp -L/usr/lib -lprometheus-cpp-core /usr/bin/ld: blackwhitelist.o: undefined reference to symbol 'pthread_rwlock_unlock@@GLIBC_2.2.5' /usr/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status For now i do not know if it is my package mistake or something other.

To Reproduce My package files are base on debian's files in builder-support directory, with some changes as they seems to be outdated. I use these build dependencies:

debhelper-compat (= 13), libboost-all-dev (>= 1.40), libgetdns-dev, libmaxminddb-dev, libsodium-dev, libsystemd-dev, libhiredis-dev, libcurl4-openssl-dev, libluajit-5.1-dev, libyaml-cpp-dev, libreadline-dev, libprotobuf-dev, libssl-dev, libc6-dev, prometheus-cpp-dev, pkg-config, protobuf-compiler, pandoc For build instructions i use:

%: dh $@

override_dh_auto_configure: dh_auto_configure -- \ --with-luajit \ --sysconfdir=/etc/wforce \ --enable-trackalert I patched Makefile to not use wget to get regexes.yaml as network access has troubles in build time. And i use debian's pbuilder to build in fresh system chroot every time.

Expected behavior I will expect, that linking will be success.

OS (please complete the following information):

OS: Debian Version 11, testing, bullseye — You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/PowerDNS/weakforced/issues/344, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADS27WHUQC7ACI5I7JYOZA3TYP3STANCNFSM5ATMSOTQ.

slavkoja commented 3 years ago

Thanks for quick reply.

On debian there are these libpthread dev packages:

Please, which one?

neilcook commented 3 years ago

You don’t need a dev package, I just mean the library for the symbols, i.e. so you end up with -lpthread in the link line,

Neil

On 19 Jul 2021, at 11:57, Slavko @.***> wrote:

Thanks for quick reply.

On debian there are these libpthread dev packages:

libpthread-stubs0-dev libpthread-workqueue-dev libpthreadpool-dev Please, which one?

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/PowerDNS/weakforced/issues/344#issuecomment-882451647, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADS27WHC2QUVR7UOJ5VNFLTTYQAK3ANCNFSM5ATMSOTQ.

slavkoja commented 3 years ago

OK, will the libpthreadpool0 package that one? Or what to search to find appropriate package?

neilcook commented 3 years ago

Sorry, but until I get round to testing this myself on debian bullseye I can't really answer this

slavkoja commented 3 years ago

I understand, but please can you tell me, which .so file i have search, i will find proper package by itself...

neilcook commented 3 years ago

libpthread.so.0

It will already be installed as part of libc,

On 19 Jul 2021, at 12:17, Slavko @.***> wrote:

I understand, but please can you tell me, which .so file i have search, i will find proper package by itself...

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/PowerDNS/weakforced/issues/344#issuecomment-882466454, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADS27WBEL63FCQPEYVPPP2DTYQCULANCNFSM5ATMSOTQ.

slavkoja commented 3 years ago

It presents already:

ls -l /lib/x86_64-linux-gnu/libpthread.so
lrwxrwxrwx 1 root root 37 May  1 20:56 /lib/x86_64-linux-gnu/libpthread.so -> /lib/x86_64-linux-gnu/libpthread.so.0

And you are right, it is installed by libc:

dpkg -S /lib/x86_64-linux-gnu/libpthread.so.0 
libc6:amd64: /lib/x86_64-linux-gnu/libpthread.so.0

Thus how to add that dependency?

slavkoja commented 3 years ago

OK, i got it to work by explicitly defining it in debian/rules file:

export DEB_LDFLAGS_MAINT_APPEND = -lpthread
omoerbeek commented 3 years ago

This should work:

diff --git a/wforce/Makefile.am b/wforce/Makefile.am
index 01c34ee..7d32a61 100644
--- a/wforce/Makefile.am
+++ b/wforce/Makefile.am
@@ -17,6 +17,7 @@ AM_CPPFLAGS = \

 AM_LDFLAGS = \
        $(PROGRAM_LDFLAGS) \
+       $(THREADFLAGS) \
        $(SANITIZER_FLAGS)

 UAP_REGEX_FILE=regexes.yaml
neilcook commented 3 years ago

Thanks Otto, I'll submit a PR with this fix at some point.

slavkoja commented 3 years ago

yes, this works too