Skip to content

esp32-hal-uart.c: race in log_printf() #5513

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

Closed
dibalavs opened this issue Aug 9, 2021 · 0 comments · Fixed by #5523
Closed

esp32-hal-uart.c: race in log_printf() #5513

dibalavs opened this issue Aug 9, 2021 · 0 comments · Fixed by #5523
Labels

Comments

@dibalavs
Copy link

dibalavs commented Aug 9, 2021

|Board|ESP32 Dev Module||
|Version/Date|framework-arduinoespressif32 3.10006.210326 (1.0.6)|
|IDE name|VSCode + Platform.io|
|Flash Frequency|80Mhz|
|PSRAM enabled|yes|
|Upload Speed|115200|
|Computer OS|Windows 10|

Description:

log_printf() function has race when it will be used from separate task.

Sketch:

int log_printf(const char *format, ...)
{
    if(s_uart_debug_nr < 0){
        return 0;
    }
    **static** char loc_buf[64];
    char * temp = loc_buf;
    int len;
....

The issue is in static keyword. so lock_buf will be shared between all tasks.
And when you will do log_e() or something els with short message, it is possible race when other task will use the same buffer.

@igrr igrr added the Type: Bug 🐛 All bugs label Aug 9, 2021
me-no-dev added a commit that referenced this issue Aug 11, 2021
Fixes: #5513

Can still race if Serial.begin() is not called in setup()
me-no-dev added a commit that referenced this issue Aug 11, 2021
Fixes: #5513

Can still race if Serial.begin() is not called in setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants