Closed roadrunner2 closed 5 years ago
I forgot to say: I was running into this problem on Fedora, where all the light values reported by iio-sensor-proxy were essentially zero. This is because Fedora builds iio-sensor-proxy (and probably most other packages) with -fstack-protector-strong
, hence triggering this bug.
Could you please test the patches in https://github.com/hadess/iio-sensor-proxy/pull/239 ?
Thanks for the quick response. The patches look good and testing them showed them working well now.
A combination of factors can cause unsigned values to be scaled to extremely small values. The relevant code snippets are (just looking at the buffered light, but is also applicable to the other buffered sensors):
If the channel is unsigned, then
ch_scale
is never assigned a value inprocess_scan_1()
, and hencescale
inprocess_scan()
is not set; furthermore, inprocess_scan()
scale is declared on the stack but not initialized. This results in the use of an uninitialized value later inprocess_scan()
. Now usually the value will happen to be 0, but e.g. if compiled with-fstack-protector-strong
then the value is actually a very small float (1.061e-314).So, first of all
scale
needs to be initialized to 0 inprocess_scan()
. Second, I don't understand why the scale is only set for unsigned data channels - I didn't see any reason why it wouldn't equally apply to signed ones.I'd be happy to create pull requests for both of these, if desired.