-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack overflow in esp_log_buffer_hexdump_internal when targeting linux 64 bit (IDFGH-12312) #13347
Comments
One more fix is needed for Linux targets, the pointer is now 64 bits so extra space is needed in esp-idf/components/log/log_buffers.c Line 123 in 60a2bf6
Something like this would fix it ? |
@matthew-8925 Thanks for pointing this out! We'll take a look at this. |
And a similar issue here raised by AddressSanitizer esp-idf/components/log/log_buffers.c Line 52 in 60a2bf6
Fix that worked for me is |
@matthew-8925 Correct, we've added this as well in a fix that should be available on master soon. |
Answers checklist.
IDF version.
v5.2 / master
Espressif SoC revision.
Linux
Operating System used.
Linux
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
None
Development Kit.
N/A
Power Supply used.
USB
What is the expected behavior?
When using
idf.py --preview set-target linux
and running code on Linux that uses ESP_LOG_BUFFER_HEXDUMP it should print without crashing.What is the actual behavior?
When using
idf.py --preview set-target linux
and running on Linux on code useing ESP_LOG_BUFFER_HEXDUMP then a stack overflow is detected and the program exits.The cause is the data buffer passed to ESP_LOG_BUFFER_HEXDUMP contains bytes with the top bit set.
That seems to be signed extended into a -64- 32 bit word when compiled for Linux and sprintf prints 8 chars instead of the expected 2.
esp-idf/components/log/log_buffers.c
Line 129 in 60a2bf6
Replacing the line with this resolved the issue.
ptr_hd += sprintf(ptr_hd, " %02x", (unsigned char)ptr_line[i]);
Steps to reproduce.
The 0xFF gets sign extended and prints as ffffffff in ESP_LOG_BUFFER_HEXDUMP. That exceeds the expected line length, smashing stack variables.
Debug Logs.
More Information.
No response
The text was updated successfully, but these errors were encountered: