Skip to content

[BUG]: Compilation Error with nginx 1.26.3 and nginx-datadog v1.6.0 - Missing <stdexcept> Include #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Simoouqas opened this issue Apr 15, 2025 · 2 comments · Fixed by #198
Labels
bug Something isn't working

Comments

@Simoouqas
Copy link

Simoouqas commented Apr 15, 2025

Module Version(s)

v1.6.0

Bug Report

Description:
When compiling the DataDog nginx module against nginx version 1.26.3 using nginx-datadog v1.6.0, the build fails with a compilation error related to missing std::out_of_range declaration.

Environment:

nginx version: 1.26.3

nginx-datadog version: 1.6.0

Compilation command: NGINX_VERSION=${NGINX_VERSION} make build

/tmp/nginx-datadog/src/tracing/directives.cpp: In function 'char* datadog::nginx::set_datadog_sample_rate(ngx_conf_t*, ngx_command_t*, void*)':
/tmp/nginx-datadog/src/tracing/directives.cpp:104:18: error: 'out_of_range' is not a member of 'std'
  104 |       throw std::out_of_range("");  // error message is in the `catch` handler
      |                  ^~~~~~~~~~~~
/tmp/nginx-datadog/src/tracing/directives.cpp:7:1: note: 'std::out_of_range' is defined in header '<stdexcept>'; did you forget to '#include <stdexcept>'?
    6 | #include "ngx_http_datadog_module.h"
  +++ |+#include <stdexcept>
    7 | 

Workaround:
Downgrading to nginx-datadog v1.5.0 resolves the compilation issue.

Suggested Fix:
The error suggests that header needs to be included in src/tracing/directives.cpp. This is a straightforward fix that should be added to the source code.

Additional Information:
I'm happy to provide:

Full build logs

System information

Test the fix once available

Any other details that would help resolve this issue

Let me know what other information would be helpful for troubleshooting this issue.

Reproduction Code

git clone --branch v1.6.0 https://github.com/DataDog/nginx-datadog.git
cd nginx-datadog/ || exit 1

NGINX_VERSION=$(get_nginx_version)

echo "Nginx version detected: ${NGINX_VERSION}"

NGINX_VERSION=${NGINX_VERSION} make build || exit 2

Error Logs

No response

Operating System

No response

@Simoouqas Simoouqas added the bug Something isn't working label Apr 15, 2025
dmehala added a commit that referenced this issue Apr 16, 2025
@dmehala
Copy link
Contributor

dmehala commented Apr 16, 2025

Hi @Simoouqas, thank you for bringing this to our attention.

That's an interesting issue. I haven't been able to reproduce it on my end, and the CI pipeline is compiling successfully. TO help narrow it down, could you let me know which compiler and version you're using?

In the meantime, as a workaround, you can try building using our Docker image with the following command:

WAF=ON ARCH=x86_64 NGINX_VERSION=1.27.1 make build-musl

You can find more details on this approach in our README here:
https://github.com/DataDog/nginx-datadog?tab=readme-ov-file#building-for-nginx

Let me know how it goes or if you run into any further issues.

@Simoouqas
Copy link
Author

Simoouqas commented Apr 16, 2025

@dmehala thank for the response

Additional Information

Here are a few more environment details that might help with debugging:

  • Compiler version:
    gcc --version
    gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309
    
  • Make version:
    make --version
    GNU Make 4.4.1
    
  • CPU architecture:
    x86_64
  • Nginx version:
    1.26.3
    
    
    

The reproduction code mentioned earlier is part of a script executed during the Docker build process, like this:

   RUN chmod +x datadog-module.sh && ./datadog-module.sh
  • What I Tried:

I attempted your approach using build-musl with my current Nginx version (1.26.3) and without enabling WAF, but encountered the following error:

  command not found
  make: *** [Makefile:105: build-musl] Error 127 

Context:

We've been using this same script for a year without any issues. However, starting around March 11, the build began failing. After reverting back to version 1.50, the script started working again.

Note:

I'm not deeply familiar with compilers or Nginx module internals, so I apologize if I'm missing or miscommunicating any important technical details. I truly appreciate your patience and guidance as we work through this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants