Skip to content

fix(vendor): update MicroPython to resolve GC false-positive #4871

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

Merged
merged 1 commit into from
Apr 3, 2025

Conversation

romanz
Copy link
Contributor

@romanz romanz commented Apr 3, 2025

@romanz romanz self-assigned this Apr 3, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs review in Firmware Apr 3, 2025
@romanz romanz added core Trezor Core firmware. Runs on Trezor Model T and T2B1. micropython Python interpreter and runtime that runs Trezor firmware labels Apr 3, 2025
@romanz romanz requested review from matejcik and mmilata April 3, 2025 08:21
Copy link

github-actions bot commented Apr 3, 2025

core UI changes device test click test persistence test
T2T1 Model T test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3B1 Safe 3 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
T3T1 Safe 5 test(screens) main(screens) test(screens) main(screens) test(screens) main(screens)
All main(screens)

@romanz romanz marked this pull request as ready for review April 3, 2025 08:47
@romanz romanz requested a review from prusnak as a code owner April 3, 2025 08:47
@romanz
Copy link
Contributor Author

romanz commented Apr 3, 2025

This false-positive (reinterpreting uninitialized memory as a heap pointer) caused MicroPython's GC to keep alive an old session module, which resulted in not calling Homescreen layout d-tor, which was holding the ImageBuffer lock.

The above resulted in a loop of MemoryError exceptions:

134167014879 trezor.workflow DEBUG setting a new default: <generator>
134167014905 trezor.loop DEBUG spawn new task: <generator object 'homescreen' at 0x7f5f5127c7a0>
134167014928 trezor.workflow DEBUG start default: <generator object 'homescreen' at 0x7f5f5127c7a0>
134167016381 trezor.loop ERROR exception:
Traceback (most recent call last):
  File "trezor/loop.py", line 162, in _step
  File "apps/homescreen/__init__.py", line 53, in homescreen
  File "trezor/ui/layouts/homescreen.py", line 92, in __init__
  File "trezor/ui/layouts/homescreen.py", line 38, in _retry_with_gc
MemoryError: 
134167016452 trezor.workflow DEBUG default closed: <generator object 'homescreen' at 0x7f5f5127c7a0>
134167016478 trezor.loop DEBUG spawn new task: <generator object 'homescreen' at 0x7f5f5125b680>
134167016501 trezor.workflow DEBUG start default: <generator object 'homescreen' at 0x7f5f5125b680>
134167017912 trezor.loop ERROR exception:
Traceback (most recent call last):
  File "trezor/loop.py", line 162, in _step
  File "apps/homescreen/__init__.py", line 53, in homescreen
  File "trezor/ui/layouts/homescreen.py", line 92, in __init__
  File "trezor/ui/layouts/homescreen.py", line 38, in _retry_with_gc
MemoryError: 
134167017976 trezor.workflow DEBUG default closed: <generator object 'homescreen' at 0x7f5f5125b680>
134167018007 trezor.loop DEBUG spawn new task: <generator object 'homescreen' at 0x7f5f5125eda0>
134167018032 trezor.workflow DEBUG start default: <generator object 'homescreen' at 0x7f5f5125eda0>
134167019375 trezor.loop ERROR exception:
Traceback (most recent call last):
  File "trezor/loop.py", line 162, in _step
  File "apps/homescreen/__init__.py", line 53, in homescreen
  File "trezor/ui/layouts/homescreen.py", line 92, in __init__
  File "trezor/ui/layouts/homescreen.py", line 38, in _retry_with_gc
MemoryError: 
...

The following patches were used to debug this issue:

@romanz romanz merged commit 6aaabd4 into main Apr 3, 2025
97 of 135 checks passed
@romanz romanz deleted the romanz/zero-vstr branch April 3, 2025 09:46
@github-project-automation github-project-automation bot moved this from 🔎 Needs review to 🤝 Needs QA in Firmware Apr 3, 2025
@bosomt bosomt moved this from 🤝 Needs QA to ✅ Approved in Firmware Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Trezor Core firmware. Runs on Trezor Model T and T2B1. micropython Python interpreter and runtime that runs Trezor firmware
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants