HackRVA / badge2024

HackRVA 2024 badge firmware and emulator
4 stars 0 forks source link

Crash on menu if you let the screensaver activate then press left/right #12

Open smcameron opened 1 month ago

smcameron commented 1 month ago
┌──/home/scameron/github/badge2024/source/core/menu.c──────────────────────────────────────────────────────────────────────────────────┐
│   326                         if (current_item == menu) { /* wrap around to last item */                                             │
│   327                                 while (!(current_item->attrib & LAST_ITEM))                                                    │
│   328                                         current_item++;                                                                        │
│   329                         } else {                                                                                               │
│   330                                 current_item--;                                                                                │
│   331                         }                                                                                                      │
│   332                         detect_infinite_loop_in_menus(menu, current_item, 0);                                                  │
│   333                                                                                                                                │
│  >334                         if (current_item->type == BACK && skip_back_item)                                                      │
│   335                                 continue;                                                                                      │
│   336                         if (current_item->attrib & exclude_attribs)                                                            │
│   337                                 continue;                                                                                      │
│   338                         break;                                                                                                 │
│   339                 }                                                                                                              │
│   340                 return current_item;                                                                                           │
│   341         }                                                                                                                      │
│   342                                                                                                                                │
│   343         #ifdef TARGET_SIMULATOR                                                                                                │
│   344         static void sanity_check_menu(struct menu_t *menu)                                                                     │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
multi-thre Thread 0x7ffff0ffd7 In: find_prev_menu_item                                                         L334  PC: 0x55555580074c 
(gdb) print current_item
$1 = (struct menu_t *) 0xffffffffffffffd8
(gdb) 

Happens in both the simulator and on the badge.

smcameron commented 1 month ago

So the problem is strange. When you press a directional button when the screensaver is active, the first one works, but the 2nd one does not.

Mitigated somewhat by:

This is not a "correct" fix though, as after the 2nd button press you are slammed to the first item on the main menu, regardless of where you were previously, which is jarring, at best. We need to re-write the menu code from scratch next year, I think.

smcameron commented 1 month ago

@warasilapm Last night, you were asking why it went to the calendar on the 2nd button press after the screen saver. This bug, and my "solution" for it, are likely part of the reason why. (I suspect it may be sort of going "back" from the "games" menu item to get to the calendar item. And it's always going back from the "games" menu item because d342eed644e463a968863c405c172d6e529c8bb8 forces it back to the games menu item when the screensaver exits.) That is all to say, if this bug could be solved correctly, maybe it would fix that too. Or, there may be more than one bug present.