Skip to content

Enable GC dump on OOM #4782

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 2 commits into from
Mar 17, 2025
Merged

Enable GC dump on OOM #4782

merged 2 commits into from
Mar 17, 2025

Conversation

romanz
Copy link
Contributor

@romanz romanz commented Mar 16, 2025

Requires the following MicroPython patch: trezor/micropython#14

@romanz romanz self-assigned this Mar 16, 2025
Copy link

github-actions bot commented Mar 16, 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 force-pushed the romanz/oom-dump branch 2 times, most recently from 0bc6093 to 4137098 Compare March 16, 2025 12:35
@romanz
Copy link
Contributor Author

romanz commented Mar 16, 2025

Manually tested on T2T1 using the following patch:

diff --git a/core/src/apps/base.py b/core/src/apps/base.py
index 5552fc86ba..0bb5d7b9ac 100644
--- a/core/src/apps/base.py
+++ b/core/src/apps/base.py
@@ -275,6 +275,16 @@ async def handle_Ping(msg: Ping) -> Success:
         from trezor.ui.layouts import confirm_action
 
         await confirm_action("ping", TR.words__confirm, "ping", br_code=B.ProtectCall)
+
+    try:
+        count = int(msg.message)
+    except ValueError:
+        count = 0
+
+    L = ['x']
+    for _ in range(count):
+        L = L + L
+
     return Success(message=msg.message)

Test steps

Collect the log with:

tio /dev/ttyACM0 | tee debug.log

Extract the JSON dump:

awk '/^\[\s?$/,/^\]\s?$/' debug.log >| dump.json 

Analyze and generate memory HTML:

core/tools/analyze-memory-dump.py dump.json 

@romanz romanz force-pushed the romanz/oom-dump branch 2 times, most recently from cc6e027 to ec2bf1f Compare March 16, 2025 18:06
@romanz romanz added core Trezor Core firmware. Runs on Trezor Model T and T2B1. micropython Python interpreter and runtime that runs Trezor firmware labels Mar 16, 2025
@romanz romanz requested review from mmilata and matejcik March 16, 2025 19:43
@romanz romanz marked this pull request as ready for review March 16, 2025 19:44
@romanz romanz requested a review from prusnak as a code owner March 16, 2025 19:44
@romanz romanz removed the request for review from prusnak March 16, 2025 19:44
@mmilata
Copy link
Member

mmilata commented Mar 17, 2025

Please also create PR in the trezor/micropython repo.

romanz added 2 commits March 17, 2025 20:17
Enabled on debug firmware and non-frozen emulator.

[no changelog]
Enabled for debug firmware and non-frozen emulator.

JSON dump can be extracted from debug log and analyzed using:

$ awk '/^\[$/,/^\]$/' <debug.log >dump.json
$ core/tools/analyze-memory-dump.py dump.json

[no changelog]
@romanz romanz merged commit 5fd168c into main Mar 17, 2025
96 checks passed
@romanz romanz deleted the romanz/oom-dump branch March 17, 2025 19:45
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
None yet
Development

Successfully merging this pull request may close these issues.

2 participants