Skip to content

fix(libdd-common): crashes caused by getenv while retrieving AAS env vars#1930

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
gleocadie/fix-get-env-for-aas-env-var
Apr 30, 2026
Merged

fix(libdd-common): crashes caused by getenv while retrieving AAS env vars#1930
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
gleocadie/fix-get-env-for-aas-env-var

Conversation

@gleocadie
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR reads /proc/self/environ to populate AAS metadata (from env var) instead of using getenv.

Motivation

getenv is not thread-safe. A call can crash if another thread is calling setenv. This will invalidate the environ pointers and cause a crash.

0x79319d662c1d __GI_getenv (stdlib/stdlib/getenv.c:84)
0x7931996ccec6 std::sys::env::unix::getenv::{{closure}}
0x7931996ccdd5 std::env::_var_os
0x7931996d1acb std::env::_var
0x7931993daf7f <libdd_common::azure_app_services::RealEnv as libdd_common::azure_app_services::QueryEnv>::get_var
0x7931993da137 core::ops::function::FnOnce::call_once
0x7931994cbffb std::sync::poison::once::Once::call_once_force::{{closure}}
0x7931996d0557 std::sys::sync::once::futex::Once::call
0x7931994ca917 libdd_profiling::exporter::profile_exporter::ProfileExporter::new
0x79319933b201 ddog_prof_Exporter_new
0x79319b15695d Datadog::UploaderBuilder::build()
0x79319b157667 ddup_upload
0x793044b34f3a __pyx_pw_7ddtrace_8internal_7datadog_9profiling_4ddup_5_ddup_7upload(_object*, _object* const*, long, _object*)
_PyErr_Occurred (/usr/src/python/Include/internal/pycore_pyerrors.h:23)
_Py_CheckFunctionResult (/usr/src/python/Objects/call.c:29)
_PyObject_VectorcallTstate (/usr/src/python/Include/internal/pycore_call.h:93)
0x63ceb6009738 PyObject_Vectorcall.cold (/usr/src/python/Objects/call.c:325)
0x63ceb6030406 _PyEval_EvalFrameDefault.cold (/usr/src/python/Python/bytecodes.c:2719)
_PyObject_VectorcallTstate (/usr/src/python/Include/internal/pycore_call.h:93)
0x63ceb600a716 method_vectorcall.cold (/usr/src/python/Objects/classobject.c:69)
0x63ceb6009324 _PyObject_VectorcallTstate (/usr/src/python/Include/internal/pycore_call.h:93)
0x793198e47284 std::thread::_State_impl<std::thread::_Invoker<std::tuple<_PeriodicThread_do_start(periodic_thread*, bool)::{lambda()#1}> > >::_M_run()
0x793198e47f60 execute_native_thread_routine
0x79319d6b2ac3 start_thread (nptl/nptl/pthread_create.c:442)
0x79319d7448d0 __clone3

@gleocadie gleocadie requested a review from a team as a code owner April 28, 2026 10:01
@gleocadie gleocadie changed the title bug: Fix crashes caused by getenv while retrieving AAS env vars fix(libdd-common) crashes caused by getenv while retrieving AAS env vars Apr 28, 2026
@gleocadie gleocadie changed the title fix(libdd-common) crashes caused by getenv while retrieving AAS env vars fix(libdd-common): crashes caused by getenv while retrieving AAS env vars Apr 28, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6dfe7318d7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread libdd-common/src/azure_app_services.rs
@KowalskiThomas
Copy link
Copy Markdown
Contributor

@codex review (asking for a Codex review because I'm not exactly a Rust expert)

@github-actions
Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/gleocadie/fix-get-env-for-aas-env-var

Summary by Rule

Rule Base Branch PR Branch Change
unwrap_used 1 1 No change (0%)
Total 1 1 No change (0%)

Annotation Counts by File

File Base Branch PR Branch Change
libdd-common/src/azure_app_services.rs 1 1 No change (0%)

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 21 21 No change (0%)
datadog-live-debugger 6 6 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-remote-config 3 3 No change (0%)
datadog-sidecar 56 56 No change (0%)
libdd-common 10 10 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 5 5 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-telemetry 19 19 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 8 8 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 15 15 No change (0%)
Total 198 198 No change (0%)

About This Report

This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.

Copy link
Copy Markdown
Contributor

@KowalskiThomas KowalskiThomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this makes sense to me, but I'll wait for the Codex review to approve.

Comment thread libdd-common/src/azure_app_services.rs Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6dfe7318d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread libdd-common/src/azure_app_services.rs Outdated
@datadog-prod-us1-4
Copy link
Copy Markdown

datadog-prod-us1-4 Bot commented Apr 28, 2026

Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 84.62%
Overall Coverage: 71.79% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 8118cf6 | Docs | Datadog PR Page | Give us feedback!

Copy link
Copy Markdown
Contributor

@KowalskiThomas KowalskiThomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appreciate the change 🙇

Take the review with a grain of salt as I said I'm really not an expert here...

Copy link
Copy Markdown
Contributor

@yannham yannham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread libdd-common/src/azure_app_services.rs
Comment thread libdd-common/src/azure_app_services.rs

env::set_var("TEST_VAR_EMPTY_STRING", "");
assert_eq!(get_trimmed_env_var!("TEST_VAR_EMPTY_STRING"), None);
fn test_get_trimmed_env_var_missing() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could test read_proc_self_environ by comparing it to the current environment (obtained from the Rust stdlib), but this has a risk of flakiness, since for any reason if something else grew the environment in between, they might disagree. Thought maybe that has no risk of happening in the test binary? I don't know, I'll let you decide 😛

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.78%. Comparing base (4b2845f) to head (8118cf6).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1930      +/-   ##
==========================================
+ Coverage   71.77%   71.78%   +0.01%     
==========================================
  Files         434      434              
  Lines       69978    69999      +21     
==========================================
+ Hits        50227    50252      +25     
+ Misses      19751    19747       -4     
Components Coverage Δ
libdd-crashtracker 66.00% <ø> (-0.02%) ⬇️
libdd-crashtracker-ffi 34.47% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 85.86% <ø> (ø)
libdd-data-pipeline-ffi 71.94% <ø> (ø)
libdd-common 79.37% <84.61%> (-0.04%) ⬇️
libdd-common-ffi 73.87% <ø> (ø)
libdd-telemetry 68.09% <ø> (+0.02%) ⬆️
libdd-telemetry-ffi 19.37% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.31% <ø> (+0.04%) ⬆️
libdd-profiling 81.62% <ø> (+0.01%) ⬆️
libdd-profiling-ffi 64.36% <ø> (ø)
datadog-sidecar 29.34% <ø> (ø)
datdog-sidecar-ffi 8.41% <ø> (ø)
spawn-worker 54.69% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.26% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 89.38% <ø> (+0.11%) ⬆️
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.69% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented Apr 28, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.63 MB 7.63 MB +0% (+56 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 83.31 MB 83.35 MB +.04% (+34.82 KB) 🔍
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.10 MB 10.17 MB +.62% (+64.96 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 99.42 MB 99.45 MB +.03% (+33.60 KB) 🔍
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.19 MB 25.19 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 79.90 KB 79.90 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 184.49 MB 184.50 MB +0% (+8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 918.37 MB 918.37 MB +0% (+876 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 7.89 MB 7.89 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 79.90 KB 79.90 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.67 MB 23.67 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 46.19 MB 46.19 MB +0% (+112 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.67 MB 21.67 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 81.14 KB 81.14 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.62 MB 188.61 MB -0% (-8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 904.02 MB 904.02 MB +0% (+782 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.13 MB 6.13 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 81.14 KB 81.14 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.35 MB 25.35 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 43.67 MB 43.67 MB +0% (+112 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 74.27 MB 74.29 MB +.02% (+21.94 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.55 MB 8.55 MB +0% (+56 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.78 MB 91.81 MB +.03% (+29.56 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.20 MB 10.20 MB +.04% (+4.64 KB) 🔍

@gleocadie
Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Apr 30, 2026

View all feedbacks in Devflow UI.

2026-04-30 11:44:24 UTC ℹ️ Start processing command /merge


2026-04-30 11:44:28 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 53m (p90).


2026-04-30 12:29:34 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 43c0973 into main Apr 30, 2026
167 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the gleocadie/fix-get-env-for-aas-env-var branch April 30, 2026 12:29
iunanua added a commit that referenced this pull request May 15, 2026
# Release proposal for libdd-telemetry and its dependencies

This PR contains version bumps based on public API changes and commits
since last release.

## libdd-capabilities
**Next version:** `2.0.0`
**Semver bump:** `major`
**Tag:** `libdd-capabilities-v2.0.0`

### Commits

- feat(capablities)!: sleep & spawn capabilities (#1873)

## libdd-common
**Next version:** `4.1.0`
**Semver bump:** `minor`
**Tag:** `libdd-common-v4.1.0`

### Commits

- refactor(sampling): move the sampling logic from dd-trace-rs
[APMSP-2946] (#1927)
- feat!: added regex-lite feature (#1939)
- fix(libdd-common): crashes caused by `getenv` while retrieving AAS env
vars (#1930)

## libdd-capabilities-impl
**Next version:** `2.0.0`
**Semver bump:** `major`
**Tag:** `libdd-capabilities-impl-v2.0.0`

### Commits

- feat(capablities)!: sleep & spawn capabilities (#1873)

## libdd-shared-runtime
**Next version:** `1.0.0`
**Semver bump:** `major`
**Tag:** `libdd-shared-runtime-v1.0.0`

**Warning:** this is an initial release. Please verify that the version
and commits included are correct.


## libdd-telemetry
**Next version:** `5.0.0`
**Semver bump:** `major`
**Tag:** `libdd-telemetry-v5.0.0`

### ⚠️ major bump forced due to:

- `libdd-common`: ^3.0.2 → ^4.0.0

### Commits

- fix(libdd-telemetry): restore previous Cargo.toml version (#1993)
- feat(capablities)!: sleep & spawn capabilities (#1873)
- fix(telemetry): avoid trigger loop in telemetry worker (#1950)
- feat(telemetry)!: include dependencies and integrations in
app-extended-heartbeat (#1962)
- fix(crypto): gate libdd-common TLS features in remaining internal
crates + add CI guard (#1943)
- fix(telemetry): schedule ExtendedHeartbeat on worker start (#1910)
- fix(telemetry): skip sending empty payloads (#1894)
- feat(sidecar): wire telemetry_extended_heartbeat_interval through
SessionConfig (#1882)
- chore(telemetry): add session id support (#1817)
- ci(libdd-shared-runtime): downgrade version so publish workflow
succeeds (#1870)
- feat(runtime)!: add shared runtime (#1602)
- perf(sidecar)!: Batch ack sending & consumption (#1835)
- fix(telemetry): wire up DD_TELEMETRY_EXTENDED_HEARTBEAT_INTERVAL to
scheduler (#1824)
- feat(capabilities)!: trait architecture http (#1555)
- chore(telemetry): use weaker mem ordering for SEQ_ID (#1749)


[APMSP-2946]:
https://datadoghq.atlassian.net/browse/APMSP-2946?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: iunanua <18325288+iunanua@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants