Skip to content

Logging long strings via printk kills the logging #75015

@benediktibk

Description

@benediktibk

Describe the bug
Logging a long string via printk("%s\n", string) kills the logging.

To Reproduce

main.c:

#include <zephyr/logging/log.h>    
#include <zephyr/kernel.h>

LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);

static uint8_t test_data[2048 + 1];

int main(void)
{
    memset(test_data, 0x00, sizeof(test_data));

    for (size_t i = 0; i < sizeof(test_data) - 1; ++i) {
        test_data[i] = '0' + (i % 10);
    }

    LOG_INF("logging %i bytes", sizeof(test_data));
    printk("%s\n", test_data);

    while (true) {
        LOG_INF("still alive");
        k_sleep(K_SECONDS(1));
    }
}

prj.conf:

CONFIG_DEBUG_OPTIMIZATIONS=y
CONFIG_LOG=y
CONFIG_ASAN=y
CONFIG_SHELL=y
CONFIG_SHELL_BACKEND_SERIAL_LOG_MESSAGE_QUEUE_SIZE=8192
CONFIG_LOG_BUFFER_SIZE=8192

Using printk(test_data); instead of printk("%s\n", test_data); avoids the issue. Therefore, I assume the root cause is somewhere within cbprintf.

Expected behavior
Continous "still alive" messages after the log entry with the long string.

Impact
Not huge, as I can avoid it with the workaround explained above.

Environment
Zephyr revision: v3.7.0-rc1-397-g7f8cc43a0b5e
nucleo_f746zg

Metadata

Metadata

Assignees

Labels

area: LoggingbugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions