Commit 1d139c5
committed
profiling: guard against NULL file in timeline error observer
ddog_php_prof_zend_error_observer dereferenced the error file pointer
without a NULL check. When an uncaught exception with a NULL file location
is reported as a fatal error, the engine calls the error observer with
file=NULL (location "Unknown"); on PHP 8.0 the observer receives a raw C
string and CStr::from_ptr(NULL) segfaulted in strlen().
This crashed any PHP 8.0 CLI process with the profiler loaded and timeline
enabled (the default) whenever such a fatal error occurred, e.g. the
upstream tests Zend/tests/bug50005.phpt and Zend/tests/bug64821.3.phpt
(both build an exception with a NULL file and throw it uncaught).
NULL-guard the file pointer (PHP 8.1+ already handled NULL via the
ZendString path). Add a regression test
profiling/tests/phpt/timeline_fatal_error_null_filename.phpt. Verified the
crash is gone on 8.0 ZTS and no regression on 8.4.1 parent 07b1b58 commit 1d139c5
2 files changed
Lines changed: 61 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
248 | 253 | | |
249 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
250 | 261 | | |
251 | | - | |
252 | | - | |
253 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
254 | 265 | | |
255 | 266 | | |
256 | 267 | | |
| |||
Lines changed: 46 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
0 commit comments