Commit 55eb9e5
authored
fix(exec): don't treat shell_exec() null return as an error (#3723)
PHP's shell_exec() returns null both when a command produces no output
AND when execution fails — the two cases are indistinguishable. Flagging
null as an error causes false-positive error spans for any intentionally
silent command (e.g. Symfony's `stty 2>/dev/null` called internally by
Terminal::hasSttyAvailable()), which is especially harmful when
DD_APM_FEATURES=error_rare_sample_tracer_drop is set, since those spans
cannot be sampled out.
The fix from cff2034 (v1.8.0) added hooks on two specific Symfony
methods to suppress their spans, but the root defect in postHookShell()
remained. Any other shell_exec() call returning null — from a Symfony
bundle, third-party package, or application code — still produced an
error span.
Per PHP docs: "It is not possible to detect execution failures using
this function." Remove the null check entirely; the false return check
above it already handles the case where PHP itself cannot invoke the
shell.
Adds a regression test asserting that shell_exec('true') — which
returns null due to no output — produces a clean span with no error.
Fixes: APMS-189671 parent 3f9f490 commit 55eb9e5
2 files changed
Lines changed: 26 additions & 2 deletions
File tree
- src/DDTrace/Integrations/Exec
- tests/Integrations/Exec
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
259 | | - | |
260 | 258 | | |
261 | 259 | | |
262 | 260 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
490 | 490 | | |
491 | 491 | | |
492 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
493 | 519 | | |
494 | 520 | | |
495 | 521 | | |
| |||
0 commit comments