cpuSensor:Check object validity in async callback

Sometimes the cpusensor crash was observed. The coredump was pointing
to segmentation fault while executing callback function inside
setupRead().
Similar issue was observed in adcsensor.
Reference to the fix: 1afda6bbb6db0e266795af3229b962c32775b928

The timer cancel() in destructor cannot cancel the expired callback
handlers. In such cases if the callback handler is executed, the
object is deleted already.

Use weak_ptr to check if the object is still valid before using these
member variables/functions.
The buffer used by async_read_util must guarantee that they remain
valid until the handler is called.

Tested: Stress tested by restarting the service. Service restart will
force re-creating the CPUSensor objects.
`count=0; \
 while true; \
 do systemctl restart xyz.openbmc_project.cpusensor.service; \
 count=$((count + 1)); \
 echo $count; \
 sleep 40; \
 done `

Signed-off-by: gokulsanker <gokul.sanker.v.g@intel.com>
Signed-off-by: Arun P. Mohanan <arun.p.m@linux.intel.com>
Change-Id: I7410feb0e17c5f6d555cd042f5e5b327de1910c5
3 files changed
tree: 51aaa8765d68749e2a364ede5f21150e91b23190
  1. include/
  2. service_files/
  3. src/
  4. subprojects/
  5. tests/
  6. .clang-format
  7. .clang-ignore
  8. .clang-tidy
  9. .gitignore
  10. Jenkinsfile
  11. LICENSE
  12. MAINTAINERS
  13. meson.build
  14. meson_options.txt
  15. OWNERS
  16. README.md
README.md

dbus-sensors

dbus-sensors is a collection of sensor applications that provide the xyz.openbmc_project.Sensor collection of interfaces. They read sensor values from hwmon, d-bus, or direct driver access to provide readings. Some advance non-sensor features such as fan presence, pwm control, and automatic cpu detection (x86) are also supported.

key features

  • runtime re-configurable from d-bus (entity-manager or the like)

  • isolated: each sensor type is isolated into its own daemon, so a bug in one sensor is unlikely to affect another, and single sensor modifications are possible

  • async single-threaded: uses sdbusplus/asio bindings

  • multiple data inputs: hwmon, d-bus, direct driver access

sensor documentation