Skip to content
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

[Core] ChibiOS fix O3 and LTO breakage of extra keys and joystick #12819

Merged

Conversation

KarlK90
Copy link
Member

@KarlK90 KarlK90 commented May 6, 2021

Description

Empty extra key reports where send (observed with Wireshark) form the keyboard when O3 optimizations with LTO where enabled on GCC 10.2 (RISC-V). The root cause should be the pointer to an stack allocated report object which is invalid by the time the report is send. The fix is simple enough, the reports are allocated with a static lifetime, so pointers to them are never invalid. Joystick reports got the same treatment as the pattern is exactly the same.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

  • ?

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Empty extra key reports where send form the keyboard when O3
optimizations with LTO where enabled on GCC 10.2 (RISC-V). The root
cause should be the pointer to an stack allocated report object which is
invalid by the time the report is send. The fix is simple enough, the
reports are allocated with a static lifetime, so pointers to them are
never invalid. Joystick reports got the same treatment as the pattern is
exactly the same.
@github-actions github-actions bot added the core label May 6, 2021
Copy link
Member

@fauxpark fauxpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also need to be done for LUFA & V-USB?

@fauxpark fauxpark requested a review from a team May 6, 2021 16:12
@KarlK90
Copy link
Member Author

KarlK90 commented May 8, 2021

Does this also need to be done for LUFA & V-USB?

I'm not sure as I don't have hardware to test the changes, but giving the reports a static lifetime shouldn't hurt, so I'm applying those as well.

@drashna
Copy link
Member

drashna commented May 9, 2021

What about mousekeys?

@KarlK90
Copy link
Member Author

KarlK90 commented May 10, 2021

Mouse keys worked without any problem. report_mouse_t is already a global object and has static lifetime for ChibiOS, LUFA and V-USB.

@drashna
Copy link
Member

drashna commented Jun 7, 2021

Thanks!

@drashna drashna merged commit 49fd3c0 into qmk:develop Jun 7, 2021
mechlovin pushed a commit to mechlovin/qmk_firmware that referenced this pull request Jul 30, 2021
mechlovin pushed a commit to mechlovin/qmk_firmware that referenced this pull request Jul 30, 2021
nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
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 this pull request may close these issues.

4 participants