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

Fix: unexpected E02 from gdb m-packets #2041

Merged
merged 1 commit into from
Jan 6, 2025

Conversation

ALTracer
Copy link
Contributor

@ALTracer ALTracer commented Jan 6, 2025

Detailed description

  • This is a minor but important bugfix.
  • The existing problem is gdbserver returning unexpected read errors E02 Cannot access memory at address to otherwise normal accesses.
  • The PR solves it by fixing a mistranslated bounds-check introduced in ca. v1.10.0-1567-g de64559 of Feature/gdb packet optimization #2014.

Tested on gd32f103cb bluepillplus running bluepill.ini/stlink BMF; and BMDA; against stm32g474ce. At first I expected wrong RCC/Flash config or invalid SRAM mapping, but interactive debugging of BMDA and extended logging proved otherwise.
Note: (gdb) maintenance packet m08070000,201 triggers a 513 byte read which is rejected by BMD. Only <=512 is good because of 1024 byte RSP packet buffer.

Your checklist for this pull request

Closing issues

@dragonmux dragonmux added this to the v2.0 release milestone Jan 6, 2025
@dragonmux dragonmux added Bug Confirmed bug GDB Issue/PR related to GDB Regression Bug caused by a regression labels Jan 6, 2025
* Its purpose is to ensure that potential responses fit into RSP packet buffer
* Suppresses unexpected E02 responses on reading small SRAM/Flash variables
* Still enforces E02 to 513 byte read requests or larger
Copy link
Member

@dragonmux dragonmux left a comment

Choose a reason for hiding this comment

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

LGTM, nice work finding this bug - merging. Thank you for the contribution!

@dragonmux dragonmux merged commit 9c60b33 into blackmagic-debug:main Jan 6, 2025
36 checks passed
@perigoso
Copy link
Contributor

perigoso commented Jan 6, 2025

Thanks for the cleanup, good catch!

I see this uses alloca a couple lines down, and I do see a way we can optimize that out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Confirmed bug GDB Issue/PR related to GDB Regression Bug caused by a regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants