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 quick settings crash #71

Merged
merged 5 commits into from
Sep 16, 2023
Merged

Fix quick settings crash #71

merged 5 commits into from
Sep 16, 2023

Conversation

dylwhich
Copy link
Collaborator

Description

Makes sure that the quick settings menu never tries to fill a negative or zero number of pixels in.

This was happening because, when checkButtonQueueWrapper() is called, it uses esp_timer_get_time() to set the last select-pressed time. But then, when it's checked in the main loop, it's compared against tNowUs which was set before the swadge's main loop was called. So, the button press time is always slightly negative immediately after being pressed. If the mode's main loop took a long enough time to run, the time difference would be negative enough to cause a negative number of pixels to be drawn.

Test Instructions

I tested this by:

  1. Building the main branch and running ./swadge_emulator -lm Demo --fuzz-buttons -r fuzz_to_reproduce_qs_error.csv until the emulator crashed reasonably quickly.
  2. Then, running ./swadge_emulator -lm Demo --replay fuzz_to_reproduce_qs_error.csv a few times to make sure it crashed consistently when replaying inputs (not every time, more like 2/3 times)
  3. Saving the recorded inputs, then switching to this branch and rebuilding.
  4. Running ./swadge_emulator -lm Demo --replay fuzz_to_reproduce_qs_error.csv many times to make sure it definitely doesn't crash.

fuzz_to_reproduce_qs_errors.csv:

Time,Type,Value
56631,BtnDown,Up
56631,AccelZ,242
64024,BtnUp,Up
69127,BtnDown,Right
74032,BtnUp,Right
78431,BtnDown,B
90267,BtnDown,Start
107081,BtnDown,Right
124839,BtnUp,Right
141177,BtnUp,Start
157629,BtnDown,Right
173920,BtnDown,Select
192122,BtnDown,A
207787,BtnDown,Start
223813,BtnUp,A
240466,BtnUp,Right
258025,BtnDown,Left
274281,BtnDown,A
291157,BtnDown,Down
307237,BtnUp,A
323946,BtnDown,A
339972,BtnUp,Down
356714,BtnUp,A
373704,BtnDown,Right
390309,BtnDown,Up
406915,BtnDown,A
424166,BtnUp,Left
440291,BtnDown,Left
457751,BtnUp,Start
474133,BtnUp,Select
490673,BtnDown,Down
507123,BtnUp,Up
524363,BtnDown,Up
541519,BtnUp,Down
558197,BtnUp,Right
573918,BtnDown,Right
590881,BtnDown,Start
606795,BtnUp,Left
623627,BtnDown,Select
640152,BtnDown,Left
656059,BtnUp,Up
673298,BtnUp,Left
689700,BtnDown,Down
706591,BtnUp,A
723349,BtnDown,Up
739621,BtnUp,B
756421,BtnUp,Up
773552,BtnDown,Left
790601,BtnUp,Left
806979,BtnUp,Down
823920,BtnUp,Select
840481,BtnUp,Start
857061,BtnUp,Right
872961,BtnDown,Right
889959,BtnUp,Right
906677,BtnDown,Up
923700,BtnDown,Right
940411,BtnDown,B
956659,BtnDown,Start
973172,BtnDown,Left
989521,BtnDown,Select
1006797,BtnUp,Start
1023405,BtnUp,Right
1040806,BtnUp,Up
1056822,BtnUp,Left
1073344,BtnDown,Start
1089500,BtnUp,Select
1106270,BtnDown,A
1123406,BtnUp,B
1139970,BtnDown,Down
1156693,BtnUp,A
1173210,BtnDown,Up
1190148,BtnDown,Left
1206097,BtnUp,Up
1223349,BtnDown,Up
1239997,BtnUp,Up
1257173,BtnDown,Up
1390499,BtnDown,Right
1406469,BtnUp,Left
1425846,BtnDown,Left
1440058,BtnUp,Up
1456478,BtnDown,B
1473461,BtnUp,B
1489994,BtnUp,Down
1506481,BtnDown,Up
1523249,BtnDown,B
1538757,BtnUp,B
1556601,BtnUp,Start
1573313,BtnDown,A
1590085,BtnDown,Select
1606139,BtnDown,B
1623833,BtnUp,Left
1639618,BtnDown,Left
1657194,BtnUp,B
1673389,BtnUp,A
1689824,BtnDown,Down
1706910,BtnDown,A
1723405,BtnUp,Up
1739741,BtnDown,Start
1756435,BtnDown,B
1772711,BtnUp,A
1789986,BtnUp,Start
1806863,BtnDown,Up
1823430,BtnUp,B
1839789,BtnUp,Select
1856294,BtnUp,Up
1873522,BtnDown,B
1890229,BtnUp,Left
1906521,BtnDown,Left
1923456,BtnDown,Select
1940035,BtnDown,A
1956622,BtnUp,Left
1973392,BtnUp,A
1989890,BtnUp,Down
2006918,BtnUp,Right
2023633,BtnUp,B
2039869,BtnUp,Select
2057122,BtnDown,Up
2073293,BtnDown,Right
2088980,BtnUp,Right
2106676,BtnUp,Up
2123423,BtnDown,Up
2140182,BtnDown,B
2156992,BtnDown,Left
2173127,BtnUp,B
2190112,BtnUp,Left
2206664,BtnDown,Right
2225615,BtnDown,Left
2242163,BtnUp,Left
2258668,BtnDown,Left
2275567,BtnDown,Select
2292523,BtnUp,Select
2308939,BtnUp,Up
2325173,BtnDown,Select
2342359,BtnDown,A
2358468,BtnUp,Select
2375356,BtnDown,Select
2392251,BtnDown,Down
2408506,BtnUp,Down
2425339,BtnDown,Down
2441721,BtnUp,Down
2458754,BtnDown,B
2475830,BtnUp,Right
2492032,BtnUp,B
2508231,BtnUp,Select
2525162,BtnDown,Select
2541899,BtnUp,Left
2558486,BtnDown,Start
2575135,BtnUp,Select
2591793,BtnDown,B
2608300,BtnDown,Down
2625558,BtnDown,Select
2642207,BtnUp,B
2658859,BtnUp,Start
2675067,BtnDown,Left
2692614,BtnDown,Right
2709109,BtnDown,Up
2725177,BtnDown,B
2741984,BtnUp,B
2758395,BtnUp,Right
2775362,BtnUp,Select
2792496,BtnUp,A
2808991,BtnUp,Left
2825338,BtnUp,Up
2841989,BtnDown,A
2858384,BtnDown,Start
2875187,BtnDown,Select
2892248,BtnDown,Right
2908909,BtnUp,Down
2925769,BtnDown,B
2942094,BtnDown,Up
2958896,BtnUp,Start
2975397,BtnUp,Up
2991788,BtnDown,Start
3009252,BtnUp,B
3025517,BtnUp,Select
3041590,BtnDown,Up
3058900,BtnUp,Right
3075623,BtnDown,Select
3091979,BtnUp,Start
3108744,BtnUp,A
3125869,BtnDown,Start
3141804,BtnDown,Right
3158807,BtnUp,Right
3175826,BtnUp,Up
3192328,BtnUp,Start
3208497,BtnDown,Right
3229398,BtnDown,Start
3246225,BtnUp,Right
3262991,BtnUp,Start
3279270,BtnDown,B
3296992,BtnDown,Up
3312764,BtnUp,Up
3329510,BtnUp,B
3345942,BtnDown,A
3362508,BtnDown,Start
3379164,BtnDown,B
3396080,BtnUp,Select
3413357,BtnUp,Start
3429876,BtnDown,Start
3446333,BtnUp,A
3463404,BtnUp,Start
3480059,BtnDown,A
3496316,BtnUp,B
3512754,BtnUp,A
3529331,BtnDown,Left
3546055,BtnDown,A
3563054,BtnDown,B
3579411,BtnUp,B
3595986,BtnDown,Right
3612602,BtnUp,Right
3629606,BtnUp,Left
3645853,BtnDown,Left
3662861,BtnDown,Start
3679397,BtnDown,B
3696553,BtnUp,Left
3713591,BtnUp,B
3729593,BtnDown,Up
3746606,BtnUp,Up
3762521,BtnDown,Up
3779427,BtnDown,Select
3796358,BtnUp,Start
3812793,BtnUp,Up
3829118,BtnUp,Select
3846541,BtnDown,Right
3862722,BtnUp,A
3879368,BtnDown,Start
3896540,BtnDown,Up
3913025,BtnDown,A
3929950,BtnUp,A
3946178,BtnUp,Start
3962914,BtnUp,Up
3979635,BtnDown,Left
3995886,BtnUp,Right
4013791,BtnDown,B
4029610,BtnDown,Select
4046075,BtnUp,B
4062536,BtnUp,Left
4079238,BtnDown,A
4095792,BtnDown,Left
4112559,BtnDown,B
4129468,BtnUp,Select
4145887,BtnUp,A
4162823,BtnDown,Select
4179471,BtnUp,B
4195841,BtnDown,Down
4212803,BtnUp,Left
4231514,BtnDown,Left
4248167,BtnUp,Left
4264907,BtnDown,Left
4281505,BtnDown,Right
4298209,BtnUp,Down
4315021,BtnUp,Right
4331564,BtnDown,Up
4347824,BtnDown,A
4364555,BtnUp,Up
4381414,BtnDown,Start
4397968,BtnUp,A
4415084,BtnDown,A
4431818,BtnUp,Left
4448367,BtnDown,Right
4465142,BtnUp,A
4481550,BtnDown,B
4497919,BtnUp,Start
4514552,BtnDown,Left
4532011,BtnDown,A
4548217,BtnUp,Right
4564834,BtnUp,A
4580269,BtnDown,Up
4596970,BtnUp,B
4613743,BtnDown,Down
4630367,BtnUp,Select
4646764,BtnUp,Left
4663630,BtnUp,Down
4680139,BtnDown,A
4696936,BtnDown,Right
4713664,BtnUp,Right
4730492,BtnDown,Select
4746993,BtnDown,B
4763789,BtnUp,B
4780717,BtnDown,Left
4796829,BtnDown,Start
4813536,BtnUp,Start
4830289,BtnDown,B
4848079,BtnUp,Select
4863594,BtnUp,Left
4880448,BtnUp,B
4896843,BtnDown,B
4913763,BtnDown,Start
4930270,BtnDown,Down
4947064,BtnUp,Up
4963240,BtnUp,Down
4980618,BtnUp,Start
4996485,BtnUp,B
5013739,BtnDown,Select
5030659,BtnDown,Up
5047160,BtnDown,Down
5063839,BtnDown,Left
5080313,BtnUp,A
5097030,BtnUp,Down
5113710,BtnUp,Up
5130313,BtnDown,B
5147116,BtnDown,Up
5163895,BtnUp,Left
5180354,BtnDown,Start
5196974,BtnDown,A
5214464,BtnUp,B
5231485,BtnDown,Down
5248114,BtnDown,Right
5264824,BtnUp,Right
5281475,BtnUp,Select
5298380,BtnDown,B
5314724,BtnUp,Down
5331459,BtnUp,B
5347827,BtnDown,Right
5364489,BtnUp,Up
5381357,BtnDown,Select
5398232,BtnDown,Up
5414603,BtnUp,Start
5432159,BtnDown,B
5448375,BtnDown,Left
5464834,BtnDown,Start
5481444,BtnUp,Select
5498467,BtnUp,Up
5514554,BtnUp,Right
5531843,BtnDown,Up
5548440,BtnUp,A
5564844,BtnDown,Down
5580877,BtnDown,A
5597988,BtnUp,B
5614703,BtnUp,Down
5631262,BtnDown,Down
5648619,BtnDown,B
5664604,BtnDown,Right
5681604,BtnUp,Up
5697915,BtnUp,Down
5715306,BtnDown,Up
5731466,BtnDown,Down
5747943,BtnUp,B
5764498,BtnUp,Right
5781687,BtnUp,Up
5798087,BtnUp,Left
5814615,BtnDown,B
5831626,BtnUp,B
5848255,BtnDown,B
5864917,BtnUp,B
5881820,BtnUp,A
5897771,BtnUp,Start
5914805,BtnDown,Right
5931154,BtnDown,Left
5948118,BtnDown,Up
5964876,BtnUp,Down
5981474,BtnDown,Down
5998617,BtnUp,Up
6014156,BtnDown,A
6031421,BtnDown,Up
6047972,BtnUp,Up
6064792,BtnDown,Up
6081589,BtnUp,A
6098099,BtnDown,B
6114690,BtnUp,Down
6131136,BtnUp,B
6148226,BtnUp,Left
6164559,BtnDown,A
6181082,BtnDown,B
6198158,BtnUp,A
6213929,BtnUp,B
6232772,BtnDown,Select
6248814,BtnDown,Down
6266544,BtnUp,Up
6282282,BtnUp,Select
6299268,BtnUp,Right
6316220,BtnDown,B
6332315,BtnUp,B
6349583,BtnUp,Down
6365835,BtnDown,Right
6382641,BtnDown,Down
6398937,BtnDown,Select
6416091,BtnDown,Start
6432393,BtnUp,Right
6449378,BtnUp,Select
6466312,BtnDown,Up
6482654,BtnDown,A
6499342,BtnDown,Select
6515843,BtnUp,A
6532389,BtnDown,A
6549202,BtnUp,Select
6566136,BtnDown,B
6582336,BtnUp,A
6599719,BtnDown,Right
6616416,BtnDown,Left
6632860,BtnUp,Start
6649253,BtnUp,Up
6665880,BtnUp,B
6682402,BtnUp,Left
6699623,BtnDown,Start
6715706,BtnUp,Down
6732890,BtnDown,Select
6749056,BtnDown,B
6765889,BtnDown,Left
6782268,BtnDown,Up
6799433,BtnDown,A
6815765,BtnUp,B
6832325,BtnDown,B
6849305,BtnDown,Down
6866342,BtnUp,Start
6882844,BtnUp,Up
6898996,BtnUp,Right
6916417,BtnUp,B
6932434,BtnUp,Select
6948995,BtnDown,Start
6965853,BtnUp,A
6982357,BtnDown,Select
6999103,BtnDown,Right
7015456,BtnUp,Right
7032478,BtnDown,Right
7049222,BtnUp,Select
7065449,BtnUp,Left
7082563,BtnDown,Up
7098978,BtnUp,Right
7115762,BtnDown,B
7132394,BtnDown,Right
7149089,BtnUp,Down
7166158,BtnUp,Start
7182558,BtnUp,Up
7199484,BtnDown,A
7216231,BtnUp,A
7234552,BtnUp,Right
7250628,BtnDown,Down
7266858,BtnDown,Right
7283973,BtnUp,Right
7300152,BtnUp,B
7316921,BtnDown,Up
7334295,BtnUp,Down
7350044,BtnDown,Select
7366708,BtnUp,Select
7383807,BtnDown,Down
7400138,BtnDown,Left
7417199,BtnDown,A
7433972,BtnUp,Up
7450275,BtnDown,Up
7466834,BtnUp,Down
7483298,BtnDown,Select
7500005,BtnDown,Right
7517093,BtnUp,A
7533430,BtnUp,Right
7610911,BtnUp,Left
7631896,BtnUp,Select
7642830,BtnDown,Right
7658934,BtnDown,Start

Ticket Links

Closes #67

Readiness Checklist

  • I have run make format to format the changes
  • I have compiled the firmware and the changes have no warnings
  • I have compiled the emulator and the changes have no warnings
  • I have run make cppcheck and checked that cppcheck_result.txt has no warnings for the changes
  • I have added doxygen comments to any code used by more than one Swadge mode. This includes /*! \file comments with Design Philosophy, Usage, and Example sections for new headers.
  • I have run make docs and checked that doxy_warnings.txt has no warnings for the new code

@dylwhich dylwhich linked an issue Sep 16, 2023 that may be closed by this pull request
@AEFeinstein
Copy link
Owner

Maximally reproducible, cooooool

@AEFeinstein AEFeinstein merged commit e5c8ffc into main Sep 16, 2023
@AEFeinstein AEFeinstein deleted the fix-quick-settings-crash branch September 16, 2023 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash on start button in emulator while in mode
2 participants