#2481 closed defect (invalid)

failed (//usr/lib/x86_64-linux-gnu/libjemalloc.so.2: cannot allocate memory in static TLS block)

Reported by: konkhra@… Owned by:
Priority: major Milestone:
Component: nginx-package Version: 1.23.x
Keywords: Cc:
uname -a: Linux debian 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.23.4 (nginx-ng-quictls)
built by gcc 10.2.1 20210110 (Debian 10.2.1-6)
built with OpenSSL 1.1.1t+quic 7 Feb 2023
TLS SNI support enabled
configure arguments: --with-cc-opt='-I /usr/local/ssl/include -m64 -march=native -mtune=native -DTCP_FASTOPEN=23 -g -O3 -fstack-protector-strong -flto -ffat-lto-objects -fuse-ld=gold --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wimplicit-fallthrough=0 -fcode-hoisting -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -Wl,--as-needed -pie -L /usr/local/ssl/lib -lssl -lcrypto -lrt -ljemalloc -Wl,-z,relro -Wl,-z,now -fPIC -flto=auto -ffat-lto-objects' --prefix=/usr/share --sbin-path=/usr/sbin/nginx --modules-path=/usr/share/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=www-data --group=www-data --build=nginx-ng-quictls --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-file-aio --with-threads --with-http_v2_module --with-http_v3_module --with-stream_quic_module --with-http_ssl_module --with-pcre-jit --with-compat --with-stream --with-libatomic --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-mail --with-mail_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_addition_module --with-http_slice_module --with-http_image_filter_module=dynamic --with-http_auth_request_module --with-http_gzip_static_module --with-http_gunzip_module --with-http_sub_module --with-http_secure_link_module --add-dynamic-module=./src/nginx-devel-kit --add-dynamic-module=./src/set-misc-nginx-module-master --add-dynamic-module=./src/headers-more-nginx-module-master --add-dynamic-module=./src/nginx-length-hiding-filter-module --add-dynamic-module=./src/memc-nginx-module --add-dynamic-module=./src/testcookie-nginx-module --add-dynamic-module=./src/ngx_http_geoip2_module --add-dynamic-module=./src/njs/nginx --add-dynamic-module=./src/nginx-module-vts --add-dynamic-module=./src/nginx-brotli-module --add-dynamic-module=./src/nginx-cache-purge --add-dynamic-module=./src/echo-nginx-module --with-zlib=./src/zlib-cf --with-openssl-opt='enable-ec_nistp_64_gcc_128 enable-tls1_3 -march=native -ljemalloc' --with-debug

Description

nginx/1.23.4 compiled with dynamic-module option throws this error when is set to load the modules:

nginx: [emerg] dlopen() "/usr/share/nginx/modules/ngx_http_echo_module.so" failed (/usr/lib/x86_64-linux-gnu/libjemalloc.so.2: cannot allocate memory in static TLS block) in /etc/nginx/modules.conf.d/ngx_http_echo_module.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

Change History (1)

comment:1 by Maxim Dounin, 12 months ago

Resolution: invalid
Status: newclosed

This doesn't look like an issue in nginx, but rather an issue with TLS usage in jemalloc you are using in the particular build.

The following links look relevant:

The first link suggests that recompiling jemalloc with --disable-initial-exec-tls might help (but might not work).

Alternatively, consider not linking nginx and modules against jemalloc, but loading it with LD_PRELOAD at runtime instead, this should fix the issue you are seeing with the build.

Note: See TracTickets for help on using tickets.