esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

Warning at log when update device from 2024.7.3 to 2024.8.0 #6179

Open KitHubek opened 3 weeks ago

KitHubek commented 3 weeks ago

The problem

Updating device to newest 2024.8.0 and see this error/warning at log during update process. Update done with SUCCES mark

Adnotacja 2024-08-21 102142

Which version of ESPHome has the issue?

2024.8.0

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2024.8.2

What platform are you using?

ESP32

Board

esp32dev and esp32doit-devkit-v1 (wt32-eth01)

Component causing the issue

dont know

Example YAML snippet

No response

Anything in the logs that might be useful for us?

src/esphome/core/bytebuffer.cpp: In member function 'float esphome::ByteBuffer::get_float()':
src/esphome/core/bytebuffer.cpp:86:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   return *(float *) &value;
           ^~~~~~~~~~~~~~~~
src/esphome/core/bytebuffer.cpp: In member function 'void esphome::ByteBuffer::put_float(float)':
src/esphome/core/bytebuffer.cpp:129:61: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 void ByteBuffer::put_float(float value) { this->put_uint32(*(uint32_t *) &value); }
                                                             ^~~~~~~~~~~~~~~~~~~

Additional information

No response

MEKadan commented 3 weeks ago

Got the same. However, from my 7 devices only on those with platform nodemcuv2 which are 8266. On various ESP32 devices not

VlastiBroucek commented 3 weeks ago

Same issue here. Default Bluetooth Proxy board: m5stack-atom framework_type: esp-idf

Compiling .pioenvs/bt-proxy/src/esphome/core/component.o src/esphome/core/bytebuffer.cpp: In member function 'float esphome::ByteBuffer::get_float()': src/esphome/core/bytebuffer.cpp:86:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] return *(float *) &value; ^~~~~~~~~~~~~~~~ src/esphome/core/bytebuffer.cpp: In member function 'void esphome::ByteBuffer::put_float(float)': src/esphome/core/bytebuffer.cpp:129:61: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] void ByteBuffer::put_float(float value) { this->put_uint32(*(uint32_t *) &value); } ^~~~~~~~~~~~~~~~~~~ Compiling .pioenvs/bt-proxy/src/esphome/core/component_iterator.o

Another device with same board but farmework_type: arduino did not have the warning.

davlaw commented 3 weeks ago

Getting this with the default Bluetooth proxy code as well..

011V32 commented 3 weeks ago

Same for me with olimex-bluetooth-proxy and atom-bluetooth-proxy

zoomtronicOR commented 3 weeks ago

Same thing here except for ESP32 devices

ThiSaadeh commented 3 weeks ago

Same thing occurring while updating Everything Presence Lite.

SaszkaX commented 3 weeks ago

Same here. After update Core 2024.8.1 -> 2024.8.2 and HAOS 13.0 -> 13.1 (but there was no ESPHome update - it's still 2024.8.0), after reboot there was new update of all ESP8266 devices (GoSund P1 & GoSund SP111), same warnings. Also update done with SUCCESS.

ssieb commented 3 weeks ago

It's just a warning. It will still work and the warning will get fixed at some point.

VlastiBroucek commented 3 weeks ago

It's just a warning. It will still work and the warning will get fixed at some point.

Yes, it will (most probably, but not guaranteed) work, however casting errors/warnings are often exploited. So for security reasons, it would be good to have it fixed ASAP.

poundy commented 3 weeks ago

EDIT: search fu left me hanging here. Not the same issue I have, sorry!

Wunja commented 3 weeks ago

I've experienced this problem and it did break the application - the device became unresponsive. Sorry, I didn't capture the decode section before rolling back.

garry0garry commented 3 weeks ago

https://github.com/esphome/issues/issues/6191

moravszky commented 3 weeks ago

I get the same warning, Core: 2024.8.2 HAOS: 13.1 ESPHome: 2024.8.0

esp32: board: esp32dev framework: type: esp-idf version: recommended

compile log: src/esphome/core/bytebuffer.cpp: In member function 'float esphome::ByteBuffer::get_float()': src/esphome/core/bytebuffer.cpp:86:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] return (float ) &value; ^~~~ src/esphome/core/bytebuffer.cpp: In member function 'void esphome::ByteBuffer::put_float(float)': src/esphome/core/bytebuffer.cpp:129:61: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] void ByteBuffer::put_float(float value) { this->put_uint32((uint32_t ) &value); } ^~~~~~~

clydebarrow commented 3 weeks ago

So for security reasons, it would be good to have it fixed ASAP.

You can be assured there is no security risk - the warning is spurious, in the sense that the code is actually perfectly fine, just the linter doesn't have enough context to determine that. And that piece of code isn't at this time actually used anywhere. But it will be fixed for all the obvious reasons.

clydebarrow commented 3 weeks ago

Fixed with https://github.com/esphome/esphome/pull/7316

VlastiBroucek commented 2 weeks ago

This is still present in 2024.8.1

ssieb commented 2 weeks ago

It's only in dev, so will be in the next full release. I don't know if it will get pulled into a point release before that.

sajikur commented 2 weeks ago

I've the same warning in my esp8266 gas sensor. Everything works correctly but warning is still there Could you explain me the meaning? thanx

ssieb commented 2 weeks ago

The compiler doesn't like casting a float pointer to an int pointer like that.

sajikur commented 2 weeks ago

casting a float pointer to an int pointer

the compiler might think about doing the compiler's job without making judgments or having preferences ;)

garry0garry commented 1 week ago

ESPHome 2024.8.3 ESP8266

Compiling .pioenvs/pzem1/src/esphome/core/bytebuffer.cpp.o
src/esphome/core/bytebuffer.cpp: In member function 'float esphome::ByteBuffer::get_float()':
src/esphome/core/bytebuffer.cpp:86:11: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   86 |   return *(float *) &value;
      |           ^~~~~~~~~~~~~~~~
src/esphome/core/bytebuffer.cpp: In member function 'void esphome::ByteBuffer::put_float(float)':
src/esphome/core/bytebuffer.cpp:129:61: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
  129 | void ByteBuffer::put_float(float value) { this->put_uint32(*(uint32_t *) &value); }
      |                                                             ^~~~~~~~~~~~~~~~~~~
ssieb commented 1 week ago

It will be fixed in the next major release. There's no need to keep commenting about it. I'm only leaving this open so that people can find it and hopefully not create new issues.