Closed zvecr closed 4 years ago
LTO?
EDIT: Tried the following with LTO both on and off, on a Proton C, prints as expected in the Toolbox.
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case KC_CUST:
print_hex8(17);
print(": ");
print_bin_reverse32((uint32_t) 0x00000000);
print("\n");
return false;
}
}
return true;
}
LTO was off in my case.
Unless someone gets there first, I need to sit down with my box of hardware at the weekend to work out whats going on. f072 has some other gremlins around backlight, so I wouldnt be surprised if this issue is only reproducible on that chip.
Just ran into this myself. The problem is a fixed-size buffer in the printf()
implementation.
What's happening: The print_bin_reverse16
and print_bin_reverse32
macros call xprintf("%016b", ...)
(or %032b
); this resolves to the printf
implementation in tmk_core
(not the one in ChibiOS, which doesn't even support the %b
specifier); and since the output is longer than the buffer, it smashes the call stack.
The buffer is 12 bytes long, which is exactly enough for octal output of a 32-bit quantity (traditional printf doesn't have any bases smaller than octal), but when binary-formatted was added to this printf implementation, this became a bug.
In my case the visible result was a local variable in a calling function getting mysteriously mutated, but an outright crash is also likely. You can see that your loop counter is getting overwritten also — the 303030
prefix is ASCII 0
getting written into the high bytes.
@wiml nice detective work! Looks like i missed that when i was last in there, as my issue was diagnosed with a ortho_4x12 board...
Describe the Bug
With
debug_matrix=true
, on a f072 prototype with 17 columns, the first keypress outputs tohid_listen
:Then no other key output happens, though
lsusb
still shows the device.Removing 1 column, and the issue disappears.
System Information
Additional Context
There seems to be only 2 other boards in the repo that fit the criteria:
Only the candybar is f072, so I presume this is not a common enough setup for it to be noticed....