Skip to content

[BUG]: Compilation failure with Debian 13, nginx 1.29.2, and nginx-datadog 1.9.0 #269

@budjb

Description

@budjb

Module Version(s)

1.9.0

Bug Report

I have a Dockerfile that will build the nginx-datadog extension for the nginx unprivileged image. The build failed recently due to #243, but even after that fix, I am seeing a new compilation failure.

Reproduction Code

The following code is a complete Dockerfile that should replicate the failure.

ARG NGINX_VERSION=1.29.2
ARG DD_NGINX_AGENT_VERSION=v1.9.0

FROM debian:trixie AS dd-agent

ARG NGINX_VERSION
ARG DD_NGINX_AGENT_VERSION

RUN apt-get update && \
    apt-get install -y \
        build-essential \
        make \
        cmake \
        git \
        curl \
        libpcre2-dev \
        zlib1g-dev \
        libssl-dev && \
    rm -rf /var/lib/apt/lists/*
WORKDIR /opt/dd
RUN git clone https://github.com/DataDog/nginx-datadog.git
WORKDIR /opt/dd/nginx-datadog
RUN git checkout  -B "$DD_NGINX_AGENT_VERSION" "$DD_NGINX_AGENT_VERSION"
RUN git submodule update --init --recursive
RUN curl -s -S -L -o nginx.tar.gz "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" && \
    mkdir nginx && \
    tar xzf nginx.tar.gz -C nginx --strip-components 1 && \
    rm nginx.tar.gz
RUN NGINX_VERSION=$NGINX_VERSION \
    CFLAGS="-fPIC" \
    CXXFLAGS="-fPIC" \
    make build -j$(nproc)

FROM nginxinc/nginx-unprivileged:$NGINX_VERSION
USER 0
COPY --from=dd-agent /opt/dd/nginx-datadog/.build/ngx_http_datadog_module.so /usr/lib/nginx/modules/
RUN printf "load_module modules/ngx_http_datadog_module.so;\n$(cat /etc/nginx/nginx.conf)" > /etc/nginx/nginx.conf
USER 101

Error Logs

#20 79.66 /usr/bin/c++ -DDD_NGINX_FLAVOR=\"nginx\" -I/opt/dd/nginx-datadog/src -I/opt/dd/nginx-datadog/dd-trace-cpp/include -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/event -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/http/modules -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/http -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/os/unix -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/objs -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/core -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/stream -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/http/v2 -isystem /opt/dd/nginx-datadog/.build/_deps/nginx-src/src/event/modules -isystem /opt/dd/nginx-datadog/.build/_deps/rapidjson-src/include -isystem /opt/dd/nginx-datadog/.build/_deps/cppcodec-src -fPIC -O2 -g -DNDEBUG -std=gnu++20 -fPIC -Wno-error=free-nonheap-object -Wno-error=maybe-uninitialized -fno-omit-frame-pointer -Wall -Werror -MD -MT CMakeFiles/ngx_http_datadog_objs.dir/src/datadog_variable.cpp.o -MF CMakeFiles/ngx_http_datadog_objs.dir/src/datadog_variable.cpp.o.d -o CMakeFiles/ngx_http_datadog_objs.dir/src/datadog_variable.cpp.o -c /opt/dd/nginx-datadog/src/datadog_variable.cpp
#20 80.10 /opt/dd/nginx-datadog/src/common/headers.cpp: In function 'bool datadog::common::remove_header(ngx_list_t&, std::string_view)':
#20 80.10 /opt/dd/nginx-datadog/src/common/headers.cpp:67:22: error: 'unique_ptr' is not a member of 'std'
#20 80.10    67 |   auto key_lc = std::unique_ptr<u_char[]>{new u_char[key.size()]};
#20 80.10       |                      ^~~~~~~~~~
#20 80.10 /opt/dd/nginx-datadog/src/common/headers.cpp:4:1: note: 'std::unique_ptr' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
#20 80.10     3 | #include "string_util.h"
#20 80.10   +++ |+#include <memory>
#20 80.10     4 | 
#20 80.10 /opt/dd/nginx-datadog/src/common/headers.cpp:67:39: error: expected primary-expression before '[' token
#20 80.10    67 |   auto key_lc = std::unique_ptr<u_char[]>{new u_char[key.size()]};
#20 80.10       |                                       ^
#20 80.10 /opt/dd/nginx-datadog/src/common/headers.cpp:67:40: error: expected primary-expression before ']' token
#20 80.10    67 |   auto key_lc = std::unique_ptr<u_char[]>{new u_char[key.size()]};
#20 80.10       |                                        ^
#20 80.10 /opt/dd/nginx-datadog/src/common/headers.cpp:67:42: error: expected primary-expression before '{' token
#20 80.10    67 |   auto key_lc = std::unique_ptr<u_char[]>{new u_char[key.size()]};
#20 80.10       |                                          ^
#20 80.23 gmake[3]: *** [CMakeFiles/ngx_http_datadog_objs.dir/build.make:107: CMakeFiles/ngx_http_datadog_objs.dir/src/common/headers.cpp.o] Error 1
#20 80.23 gmake[3]: *** Waiting for unfinished jobs....
#20 83.16 gmake[3]: Leaving directory '/opt/dd/nginx-datadog/.build'
#20 83.16 gmake[2]: *** [CMakeFiles/Makefile2:1594: CMakeFiles/ngx_http_datadog_objs.dir/all] Error 2
#20 83.16 gmake[2]: Leaving directory '/opt/dd/nginx-datadog/.build'
#20 83.16 gmake[1]: *** [Makefile:146: all] Error 2
#20 83.16 gmake[1]: Leaving directory '/opt/dd/nginx-datadog/.build'
#20 83.16 
#20 83.16 make: *** [Makefile:24: build] Error 2

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions