critical bug report + troubleshooting


Yesterday i received a bug report that is serious enough to warrant a full blogpost, although it's relatively unlikely to be triggered. 

Here's how to trigger it /avoid it, what problems it causes, and how to repair the damage in case this would happen to you.


Severity: 
-if triggered, it may corrupt nexxt's work memory - likely affecting metatile set labels.
-that corruption may get saved onto an .nss file.
-that save file will need manual repair to be openable again, due to an unhandled exception.


Action plan:
I'll try to have this bug resolved in the next release. 
A link to this blogpost will be added to the 'known bugs' post on the help forum meanwhile. 


Trigger steps - avoid part A, avoid the bug:

bug part A:
1 )  Have a map larger than a single NES screen
2 )  Box-Select a portion larger than one screen
(this can be done either on the navigator [f6] canvas, or through the 'select all' command).
3 - critical )  Using the swap action (right mouse button within the map selection; then drag), drag it outside the boundaries of the map. The test case was up-outside. NEXXT is missing a safeguard against this invalid action. 
4 )  Step 3 will cause NEXXT to try to overwrite memory it shouldn't. NEXXT will soft-crash (showing a warning message or two), but technically you can continue to work. however...
5 )  A portion of unrelated work memory is now highly likely to be corrupted in a particular way.
bug part B:
6 - critical )  Save the corrupted memory as a session (.nss) file
7 )  Attempt to open that same (.nss) session file
8 )  NEXXT will now crash; failing to load the file.

Detailed bug description:
This combination of actions don't have enough guard rails, and so the portion of the map you're swapping is attempting to write to memory outside the maps' allocation. You will get some kind of warning message, like "scanline out of range" or "access violation" - this can vary. 

In this particular case, memory protection isn't working, and so a portion of unrelated work ram is overwritten. This work ram seems to consistently be the metatile set labels. Most session files don't make use of these, so it seems nontrivial enough. However, if the label strings are completely erased (likely if the top of your dragged map portion was filled with tile # 00), NEXXT will save 'empty' label tags if you choose to save that file. NEXXT does not know how to handle an empty tag supposed to be read like a string, and will hard-crash on attempting to load a session file corrupted in such a way (a 'solitaire' cascade of warning messages).

In case of file corruption - repair method 1:
1) open the corrupted .nss file in a text/code editor
2) look for anywhere where a tag has missing data, eg. like so:

MetatileSetLabels_2x2=
MetatileSetLabels_2x2Undo=

3) open a 'healthy' session file and copy over what it's supposed to look like, eg:

MetatileSetLabels_2x2=Unlabeled,Unlabeled,Unlabeled,Unlabeled
MetatileSetLabels_2x2Undo=Unlabeled,Unlabeled,Unlabeled,Unlabeled

Putting anything after the "=" is probably going to work, but it's probably best to try to match the expected case.

Repair method 2:


In case the session file is corrupted in a way not covered here, the more general method to repair a file and pinpoint the cause is this:
1) cut out one large portion of non-essential data from the .nss file. save.
2) open that savefile in nexxt. if a tag is missing, nexxt will generally assume a default value which can prevent it from crashing. 
3) if happy with the results, feel free to save that file. it's now repaired.
4) if you wish to pinpoint the cause further, narrow down the block you cut out to the exact errant line. This is both less invasive, and more useful to report. 

If all else fails:
-Send the file to me and I'll investigate it further, and will attempt to repair the file for you. 


Get NEXXT studio 3.6.2

Leave a comment

Log in with itch.io to leave a comment.