Skip to content

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

Closed
@dibalavs

Description

@dibalavs

|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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions