sipwise / rtpengine

The Sipwise media proxy for Kamailio
GNU General Public License v3.0
785 stars 368 forks source link

compile error in dtmf_rx_fillin with ASAN #1751

Closed andingv closed 11 months ago

andingv commented 11 months ago

Trying to build the rtpengine (mr12.0 in this case, but starting point was mr10.5.4) for Alpine with ASAN the dtmf_rx_fillin-02.h as well as dtmf_rx_fillin-01.h failed to compile.

The ffmpeg should be also built from source, the spandsp comes from apk.

When asan is disabled, the compilation works successfully, at least with mr10.5.4 (see next snipped and comment below). Is there an easy way to disable ASAN for the dependency libraries like ffmpeg ? If it should be enabled all the way down to ffmpeg, because we want ASAN for the main daemon code, is there anything else to validate regarding the compilation error?

c -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -DASAN_BUILD -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\""   -c -o tcp_listener.o tcp_listener.c
../utils/build_test_wrapper "dtmf_rx_fillin.h" 2> /dev/null
Looking for usable alternative for dtmf_rx_fillin.h
Trying build with ../lib/dtmf_rx_fillin-01.h
make[3]: Entering directory '/tmp/build/daemon'
cc -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -DASAN_BUILD -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\""  -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -rdynamic -rdynamic -rdynamic -rdynamic  dtmf_rx_fillin-test.c  -lm -ldl -lglib-2.0 -lintl  -lgthread-2.0 -pthread -lglib-2.0 -lintl  -L/lib -lz  -lpcre2-8  -lcrypto  -lssl -lcrypto  -levent_pthreads -levent  -lpcap -lxmlrpc_client -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util  -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util  -lxmlrpc_util  -lhiredis -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -lwebsockets  -lnftnl  -lmnl  -lip4tc -lip6tc  -lavcodec  -lavformat  -lavutil  -lswresample  -lavfilter  -lspandsp  -lopus  -L/usr/lib/ -lmariadb -L/usr/usr/lib -lbcg729  -lmosquitto  -o dtmf_rx_fillin-test
make[3]: Leaving directory '/tmp/build/daemon'
Failed build with ../lib/dtmf_rx_fillin-01.h
Trying build with ../lib/dtmf_rx_fillin-02.h
make[3]: Entering directory '/tmp/build/daemon'
cc -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -DASAN_BUILD -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\"" -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\""  -ggdb -O0 -fsanitize=address -fsanitize=leak -fsanitize=undefined -rdynamic -rdynamic -rdynamic -rdynamic  dtmf_rx_fillin-test.c  -lm -ldl -lglib-2.0 -lintl  -lgthread-2.0 -pthread -lglib-2.0 -lintl  -L/lib -lz  -lpcre2-8  -lcrypto  -lssl -lcrypto  -levent_pthreads -levent  -lpcap -lxmlrpc_client -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util  -lxmlrpc -lxmlrpc_xmlparse -lxmlrpc_xmltok -lxmlrpc_util  -lxmlrpc_util  -lhiredis -ljson-glib-1.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl  -lwebsockets  -lnftnl  -lmnl  -lip4tc -lip6tc  -lavcodec  -lavformat  -lavutil  -lswresample  -lavfilter  -lspandsp  -lopus  -L/usr/lib/ -lmariadb -L/usr/usr/lib -lbcg729  -lmosquitto  -o dtmf_rx_fillin-test
make[3]: Leaving directory '/tmp/build/daemon'
Failed build with ../lib/dtmf_rx_fillin-02.h
make[2]: *** [../lib/common.Makefile:57: dtmf_rx_fillin.h] Error 1
rm control_ng.strhash.c sdp.strhash.c call_interfaces.strhash.c
make[2]: Leaving directory '/tmp/build/daemon'
make[1]: *** [../lib/common.Makefile:4: all] Error 2
make[1]: Leaving directory '/tmp/build/daemon'
make: *** [Makefile:22: all] Error 2
The command '/bin/sh -c cd /tmp/build     && DO_ASAN_FLAGS=1 make all     && mkdir -p /usr/lib/xtables/     && cp /tmp/build/iptables-extension/libxt_RTPENGINE.so /usr/lib/xtables/     && cp /tmp/build/daemon/rtpengine /tmp/build/recording-daemon/rtpengine-recording /usr/sbin/     && cp /tmp/build/utils/rtpengine-ctl /usr/bin/     && /extract-debug.sh         /usr/sbin/rtpengine         /usr/sbin/rtpengine-recording         /usr/lib/xtables/libxt_RTPENGINE.so     && /build-image.sh' returned a non-zero code: 2

thank you.

ps. without ASAN, it worked for me with 10.5.4, while in mr12.0 i got another error i have not yet looked into

cc -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type -Wshadow -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\""   -c -o ssllib.o ssllib.c
( echo '/******** GENERATED FILE ********/' && \
    echo '#line 1' && \
    cat ../lib/"dtmflib.c" ) > "dtmflib.c"
cc -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type -Wshadow -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\""   -c -o dtmflib.o dtmflib.c
( echo '/******** GENERATED FILE ********/' && \
    echo '#line 1' && \
    cat ../lib/"mix_buffer.c" ) > "mix_buffer.c"
cc -g -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wstrict-prototypes -Werror=return-type -Wshadow -pthread -fno-strict-aliasing -std=c11 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include     -DPCRE2_CODE_UNIT_WIDTH=8     -I/usr/include/json-glib-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid      -DWITH_IPTABLES_OPTION -I. -I../kernel-module/ -I../lib/ -I../include/ -D_GNU_SOURCE       -I/usr/include/opus  -DWITH_TRANSCODING -I/usr/include/mysql -I/usr/include/mysql/mysql -DHAVE_BCG729  -DHAVE_MQTT  -DRTPENGINE_VERSION="\"undefined\""   -c -o mix_buffer.o mix_buffer.c
mix_buffer.c:66:27: error: 'ifunc' is not supported on this target
   66 |         return s16_mix_in_c;
      |                           ^~        
make[2]: *** [<builtin>: mix_buffer.o] Error 1
rm control_ng.strhash.c sdp.strhash.c janus.strhash.c call_interfaces.strhash.c
make[2]: Leaving directory '/tmp/build/daemon'
make[1]: *** [../lib/common.Makefile:4: all] Error 2
make[1]: Leaving directory '/tmp/build/daemon'
make: *** [Makefile:22: all] Error 2
The command '/bin/sh -c cd /tmp/build     && make all     && mkdir -p /usr/lib/xtables/     && cp /tmp/build/iptables-extension/libxt_RTPENGINE.so /usr/lib/xtables/     && cp /tmp/build/daemon/rtpengine /tmp/build/recording-daemon/rtpengine-recording /usr/sbin/     && cp /tmp/build/utils/rtpengine-ctl /usr/bin/     && /extract-debug.sh         /usr/sbin/rtpengine         /usr/sbin/rtpengine-recording         /usr/lib/xtables/libxt_RTPENGINE.so     && /build-image.sh' returned a non-zero code: 2
rfuchs commented 11 months ago

Is this not gcc? Why doesn't it support ifunc?

andingv commented 11 months ago

It uses gcc but with musl instead of libc, where ifunc may be not available. I noted that i may need another base OS for the container image in rel > mr10.5

Not sure how to compile the old one with asan, since mr10.5.4 has served me well on this base Alpine OS for k8s container for a bit. Now I am noticing some memory leak when running load of AMR transcoding, which I wanted to dig into, so maybe the Debian is the way to go anyway.

andingv commented 11 months ago

Thank you, that brought me many steps further. Still unsure why neither dtmf_rx_filling 01/02 compiles in this environment, when the asan flag is set.