Crash and FRAM corruption when launching stage selection mode #21

Closed
opened 2022-02-23 14:29:31 -04:00 by ZAdamMac · 2 comments
ZAdamMac commented 2022-02-23 14:29:31 -04:00 (Migrated from github.com)

When entering the "stage select" mode via the debug menu, the screen will go blank. Subsequent BOR does nothing to relieve the condition.

Inspection via Debugger reveals the following behaviour:

  • The button press to select the stage select option is registered
  • The function in the debug menu which corresponds to this triggers, and sets SCENE_ACT correctly to 0xF3, the registered address for that scene.
  • The menu generator correctly generates the subsequent frame of information (Note: This is disputed, reconfirm)
  • The screen refresh happens correctly.
  • The menu generator exit condition is met and we leave the scene.
  • The VCOM transition happens as intended.
  • The instruction to enter LPM is reached.

Thereafter the execution pointer appears to leap into the bootloader in perpetuity.

When entering the "stage select" mode via the debug menu, the screen will go blank. Subsequent BOR does nothing to relieve the condition. Inspection via Debugger reveals the following behaviour: - The button press to select the stage select option is registered - The function in the debug menu which corresponds to this triggers, and sets `SCENE_ACT` correctly to `0xF3`, the registered address for that scene. - The menu generator correctly generates the subsequent frame of information (Note: This is disputed, reconfirm) - The screen refresh happens correctly. - The menu generator exit condition is met and we leave the scene. - The VCOM transition happens as intended. - The instruction to enter LPM is reached. Thereafter the execution pointer appears to leap into the bootloader in perpetuity.
ZAdamMac commented 2022-03-01 07:07:10 -04:00 (Migrated from github.com)

Some testing was conducted on this last night with the following results:

  • Disproved a hypothesis that the corruption was coming from the Debug Menu's function that sets the active scene. This was already not expected to be the cause, but as a proof of concept the address was temporarily changed to the main game scene and exited successfully.
  • Failed to disprove a hypothesis that the corruption was coming from the Stage Select menu itself by setting Stage Select as the initial boot scene.This caused, at least from the outside looking in, similar crashing behaviour, which thankfully resolved when setting the default behaviours back.

Based on this it is likely the issue is in the Stage Select. Attention should be paid to the following three most likely causes:

  1. Use of strcpy vs strncpy and the corresponding risks of overflow, which has happened in the past.
  2. The length of the "strings" in the array of stage names needs to be revalidated. Fixing 1 would obviate this.
  3. The new directive logic, which was thought to be validated by its usage in other scenes, should be revalidated.
Some testing was conducted on this last night with the following results: - Disproved a hypothesis that the corruption was coming from the Debug Menu's function that sets the active scene. This was already not expected to be the cause, but as a proof of concept the address was temporarily changed to the main game scene and exited successfully. - Failed to disprove a hypothesis that the corruption was coming from the Stage Select menu itself by setting Stage Select as the initial boot scene.This caused, at least from the outside looking in, similar crashing behaviour, which thankfully resolved when setting the default behaviours back. Based on this it is likely the issue is in the Stage Select. Attention should be paid to the following three most likely causes: 1. Use of `strcpy` vs `strncpy` and the corresponding risks of overflow, which has happened in the past. 2. The length of the "strings" in the array of stage names needs to be revalidated. Fixing 1 would obviate this. 3. The new directive logic, which was thought to be validated by its usage in other scenes, should be revalidated.
ZAdamMac commented 2022-03-02 20:16:40 -04:00 (Migrated from github.com)

Resolved with commit d1948de.

Issue was calling a MENU function that should have been explicitly recalled to SCENESEL

Resolved with commit d1948de. Issue was calling a MENU function that should have been explicitly recalled to SCENESEL
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zadammac/PETI#21
No description provided.