Skip to content

Conversation

@morrisonlevi
Copy link
Collaborator

@morrisonlevi morrisonlevi commented Jan 13, 2026

https://datadoghq.atlassian.net/browse/PROF-11119

Description

The uploader calls getenv and crashes, a classic here in PHP. Fortunately this specific one is a low-volume crash because it's behind a lock, so if it succeeds once, that process is then safe.

Also fortunately, the lock is pub so we can force it to initialize on first request, which is how we fix it.

Crash Backtrace
#0   0x00007f10a987914d getenv 
#1   0x00007f10a50b9263 std::sys::pal::unix::os::getenv::{{closure}}::h6378d1a598548b0a (sys/pal/unix/os.rs:665:26)
#2   0x00007f10a50b8e68 std::sys::pal::common::small_c_string::run_with_cstr_stack::ha6758cc058ac984d (common/small_c_string.rs:48:18)
#3   0x00007f10a50b8e68 std::sys::pal::common::small_c_string::run_with_cstr::h7dac442e96153d9b (common/small_c_string.rs:28:18)
#4   0x00007f10a50b8e68 std::sys::pal::unix::os::getenv::h3d60d140518f3acb (sys/pal/unix/os.rs:663:5)
#5   0x00007f10a50b8e68 std::env::_var_os::h394429332d906ed4 (std/src/env.rs:262:5)
#6   0x00007f10a4f0fcbd std::env::var_os::h991487127498c269 (std/src/env.rs:258:5)
#7   0x00007f10a4f0fcbd std::env::_var::hcfe40ad695553b79 (std/src/env.rs:225:11)
#8   0x00007f10a4f0fcbd var<&str> (std/src/env.rs:221:5)
#9   0x00007f10a4f0fcbd str_not_empty (src/config.rs:26:9)
#10  0x00007f10a4f0fcbd {closure#0} (src/entity_id/mod.rs:97:40)
#11  0x00007f10a4f0fcbd call_once<libdd_common::entity_id::DD_EXTERNAL_ENV::{closure_env#0}, ()> (src/ops/function.rs:250:5)
#12  0x00007f10a4f28335 call_once<fn() -> core::option::Option<&str>, ()> (src/ops/function.rs:250:5)
#13  0x00007f10a4f28335 {closure#0}<core::option::Option<&str>, fn() -> core::option::Option<&str>> (sync/lazy_lock.rs:212:25)
#14  0x00007f10a4f28335 {closure#0}<std::sync::lazy_lock::{impl#0}::force::{closure_env#0}<core::option::Option<&str>, fn() -> core::option::Option<&str>>> (std/src/sync/once.rs:158:41)
#15  0x00007f10a4e79c44 std::sys::sync::once::futex::Once::call::h145fbd026d17cf56 (sync/once/futex.rs:176:21)
#16  0x00007f10a4f5114f call_once<std::sync::lazy_lock::{impl#0}::force::{closure_env#0}<core::option::Option<&str>, fn() -> core::option::Option<&str>>> (std/src/sync/once.rs:158:9)
#17  0x00007f10a4f5114f force<core::option::Option<&str>, fn() -> core::option::Option<&str>> (sync/lazy_lock.rs:208:9)
#18  0x00007f10a4f5114f deref<core::option::Option<&str>, fn() -> core::option::Option<&str>> (sync/lazy_lock.rs:311:9)
#19  0x00007f10a4f5114f to_request_builder (src/lib.rs:270:37)
#20  0x00007f10a4f5114f build (src/exporter/mod.rs:318:23)
#21  0x00007f10a4e8c122 upload (profiling/uploader.rs:86:23)
#22  0x00007f10a4e8c122 run (profiling/uploader.rs:134:43)
#23  0x00007f10a4e8c122 {closure#1} (src/profiling/mod.rs:703:17)
#24  0x00007f10a4e8c122 {closure#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()> (profiling/thread_utils.rs:46:13)
#25  0x00007f10a4e8c122 __rust_begin_short_backtrace<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()> (src/sys/backtrace.rs:154:18)
#26  0x00007f10a4e94460 {closure#0}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()> (src/thread/mod.rs:561:17)
#27  0x00007f10a4e94460 call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()>> (panic/unwind_safe.rs:272:9)
#28  0x00007f10a4e94460 do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()>>, ()> (std/src/panicking.rs:557:40)
#29  0x00007f10a4e94460 try<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()>>> (std/src/panicking.rs:520:19)
#30  0x00007f10a4e94460 catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()>>, ()> (std/src/panic.rs:358:14)
#31  0x00007f10a4e94460 {closure#1}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()> (src/thread/mod.rs:559:30)
#32  0x00007f10a4e94460 call_once<std::thread::{impl#0}::spawn_unchecked_::{closure_env#1}<datadog_php_profiling::profiling::thread_utils::spawn::{closure_env#0}<datadog_php_profiling::profiling::{impl#5}::new::{closure_env#1}, ()>, ()>, ()> (src/ops/function.rs:250:5)
#33  0x00007f10a50bdefb <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0bbb114b77b490c1 (alloc/src/boxed.rs:1972:9)
#34  0x00007f10a50bdefb <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3673811012fc0688 (alloc/src/boxed.rs:1972:9)
#35  0x00007f10a50bdefb std::sys::pal::unix::thread::Thread::new::thread_start::h0feaf4a9a4b2ecde (pal/unix/thread.rs:105:17)
#36  0x00007f10a9942a40 __clone 

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@morrisonlevi morrisonlevi requested a review from a team as a code owner January 13, 2026 16:55
@datadog-official
Copy link

datadog-official bot commented Jan 13, 2026

⚠️ Tests

Fix all issues with Cursor

⚠️ Warnings

🧪 1022 Tests failed

    testSearchPhpBinaries from integration.DDTrace\Tests\Integration\PHPInstallerTest (Fix with Cursor)

testSimplePushAndProcess from laravel-58-test.DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V5_8\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 6966893d000000001bd609252d36fe19
tid: 6966893d00000000
hexProcessTraceId: 1bd609252d36fe19
hexProcessSpanId: 8350bb344d54579f
processTraceId: 2005800739317153305
processSpanId: 9462268650415478687

phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:106
testSimplePushAndProcess from laravel-8x-test.DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest (Datadog) (Fix with Cursor)
DDTrace\Tests\Integrations\Laravel\V8_x\QueueTest::testSimplePushAndProcess
Test code or tested code printed unexpected output: spanLinksTraceId: 69667bbb000000006edaebabbb90d575
tid: 69667bbb00000000
hexProcessTraceId: 6edaebabbb90d575
hexProcessSpanId: 45d0939f0328ea4a
processTraceId: 7987956011913762165
processSpanId: 5030683094934940234
View all

ℹ️ Info

❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c33cdf7 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.92%. Comparing base (2c70c61) to head (c33cdf7).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3576      +/-   ##
==========================================
- Coverage   62.01%   61.92%   -0.10%     
==========================================
  Files         140      140              
  Lines       13309    13309              
  Branches     1762     1762              
==========================================
- Hits         8253     8241      -12     
- Misses       4268     4278      +10     
- Partials      788      790       +2     

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c70c61...c33cdf7. Read the comment docs.

🚀 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants