N64-UNFLoader: Parsing commands leads to system crash when compiled with debug mode disabled

This is a continuation of the discussion from #66, so that it isn’t lost in a closed PR.

I was thinking about the issue, and figured it would be easy to modify one of the examples to capture the spirit of what I’m trying to do with my code. That is to compile using release libraries and optimisation enabled, while also retaining the ability to communicate with the ROM using UNFLoader’s command parser.

I was able to reproduce the issue with example 4, using Crash’s SDK: https://github.com/tristanpenman/N64-UNFLoader/commit/9dd913742ba259cf7f23184a13b194ae3002327d

This commit sets DEBUG_MODE = 0 in GNUMakefile, but still includes the code from debug.c in the final build. debug.h has been modified to set OVERWRITE_OSPRINT = 0, since the required symbols are not included in the release libraries.

When running this ROM on an Everdrive X7, sending the rotate command is enough to crash the system.

This seems like a good starting point for continuing to investigate the issue, and I’ll continue digging into it when time allows 😅

At this stage, I’m not even sure it is safe to assume that this is a memory alignment issue. So @rasky and @buu342, if you have any ideas that are worth exploring, let me know and I’ll try to carve away some time to try them out.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 25 (25 by maintainers)

Most upvoted comments

When it crashes, there is no debug output through USB.

Here’s what it looks like in my terminal when it crashes:

UNFLoader
--------------------------------------------
Cobbled together by Buu342
Compiled on Jul 20 2021

Debug mode enabled.
EverDrive autodetected!
USB connection opened.
ROM successfully uploaded in 0.06 seconds!
Debug mode started. Press ESC to stop.

Debug mode initialized!

Available USB commands
----------------------
1. ping
        Pong!
2. rotate
        Toggles square rotation
3. color R G B
        Changes the background color
4. texture @file@
        Changes the square texture

Uploading data [################] 0%
Error: Everdrive timed out.

USB connection closed.
Press any key to continue...