Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug] Corrupted console output with large buffers. #1697

@gendx

Description

@gendx

System specifications

Commands run

On Tock repository.

cd boards/nordic/nrf52840dk
make flash

On libtock-rs at my console-check branch.

./run_example console_triangle

Expected behavior

The console_triangle example from my console-check branch on libtock-rs is using the console driver with buffers of increasing size (hence the "triangle") https://github.com/gendx/libtock-rs/blob/console-check/examples/console_triangle.rs.

The output is supposed to look like this:

1
22
333
4444
55555
666666
7777777
88888888
999999999
0000000000
11111111111
222222222222
3333333333333
44444444444444
555555555555555
...

Observed behavior

With a maximum buffer size of 128 bytes, I observe corrupted console output such as the following:

...
6666666666666666666666666666666666666666666666666666666666666666666666666666
77777777777777777777777777777777777777777777777777777777777777777777777777777
888888888888888888888888888888888888888888888888888888888888888888888888888888
9999999999999999999999999999999999999999999999999999999999999999999999999999999
00000000000000000000000000000000000000000000000000000000000000000000000000000000
111111111111111111111111111111111111111111111111111111111111111111111111111111111
2222222222222222222222222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333334444444444
333333333333333333333333333333333
4444444444444445555555555555555555555555555555555555555555555
4444444444444444444444
5566666666666666666666666666666666666666666666666666666666666666666666666
7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777
88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
...

When the maximum buffer size is 64 bytes however, there's no such corrupted output.

Analysis

Incidentally, the console driver has buffers of 64 bytes, which leads me to believe that the bug could come from there.

pub static mut WRITE_BUF: [u8; 64] = [0; 64];
pub static mut READ_BUF: [u8; 64] = [0; 64];

It could also be another side-effect of alarms not working properly (see #1651).

Help wanted

I can currently only test on nRF52840-DK via Segger RTT output, so it would be helpful to know if anyone can reproduce on another board and/or on UART output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    blockedWaiting on something, like a different PR or a dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions