pyOCD race condition bugs in write_core_registers_raw and read_core_registers_raw
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 560
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 3
Description
Quoting: https://github.com/mbedmicro/pyOCD/blob/master/pyocd/coresight/cortex_m.py
# Technically, we need to poll S_REGRDY in DHCSR here before reading DCRDR. But
# we're running so slow compared to the target that it's not necessary.
# Read it and assert that S_REGRDY is set
Technically, this is a bug. And it bit me. :(
This is no longer "technically" true. 5 years of computer improvements makes this statement now false. I had to check the S_REGRDY or my probe smashed the register by executing another write too quickly and then failed the assert on the callbacks.
These comments are in the functions write_core_registers_raw and read_core_registers_raw.
I added a read to validate the S_REGRDY, but this seems like a duct tape patch. And it sort of conflicts with the whole read callback thing, so I'm kind of reluctant to submit a patch given that I really don't understand how to do this immediately and then with the callbacks in a way that isn't redundant.
Edit: Looks like I'm not the only one to see this:
https://github.com/mbedmicro/pyOCD/issues/693
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pyocd/coresight/cortex_m.py and inspect write_core_registers_raw and read_core_registers_raw, including their S_REGRDY comments and read callbacks. Read the related issue #693 for prior context. Done means the register accesses no longer race with the target and the callback behavior remains correct without assertion failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100