Commit c3e0c6d
{BugFix} Core - Initialize ImageDataRecord temperature to NaN
Summary:
Explanation:
`ImageDataRecord::temperature` had no default initializer, and the image player assigns it only when the source value is not NaN (`ImageSensorPlayer.cpp`: `if (!std::isnan(data.temperature.get()))`). Sensors without a temperature probe, such as eye-tracking cameras, report NaN, so the field was never assigned and returned uninitialized memory. Reading uninitialized memory is undefined behavior: it surfaces as a non-finite value that is non-deterministic across builds, devices, and runs -- observed as `inf` in some runs and as a benign in-range value in others. The field is documented "may be NAN", but consumers that guard with `std::isnan()` do not catch `inf` and therefore treat the value as a valid reading; it is also exposed through the Python `.temperature` attribute and the visiontypes converters.
This initializes the field to `std::numeric_limits<double>::quiet_NaN()` so that a skipped assignment yields the documented NaN deterministically instead of undefined-behavior garbage.
Reproducibility:
Before this change, reading `temperature` on an eye-tracking camera frame (whose firmware writes NaN) returned an uninitialized, indeterminate value that surfaced as `inf` in affected runs; with the initializer it deterministically returns NaN, matching the field's documented contract.
Reviewed By: SeaOtocinclus
Differential Revision: D110973770
fbshipit-source-id: f5062c9d45932d58fd9d10c5e5689b75035d09751 parent 4645e23 commit c3e0c6d
2 files changed
Lines changed: 14 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
| |||
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | | - | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
0 commit comments