"Reading outside of buffer" (DefSave) (#4727)

Hi! I’m getting the following error when loading using DefSave (1.2.0, though I get the same in 1.2.1):

ERROR:SCRIPT: /defsave/defsave.lua:119: Reading outside of buffer at element #3 (string) [value_len=1946157056]: wanted to read: 1946157060 bytes left: 102826 [BufStart: 000000013F5BB8E8, BufSize: 102844]
'NVN}KS{12|KSVBKSVBKSVBKSVBKSVBKSVBKSVBKSVBKSVBKSVBKSVBKSVB}KSVNKS{32|KN{6|KSVSKSVBKSVNKSVSKSVSKS{3|KN{3|KSVSKSVNKSVUV4}KN{3|KSVS'
stack traceback:
	[C]: in function 'load'
	/defsave/defsave.lua:119: in function 'load'

Does anyone know what this means? It’s not the end of the world because I get the error when I try to load a save file generated by another user… But I have previously been able to do that without issues (even across OS, for example Mac to Windows and then back again). The save file works fine for the user in question as far as I know. I don’t know their OS or setup, but can go back to them to ask if that’s important information.

I thought it might have something to do with my save files being too bloated (the main save of this user is ~100kb and contains some long strings of text). However, that theory came into question when I got the same error for their settings save file, which is ~1kb and just contains a bunch of basic bools, keymaps, and stuff like that.

(Pinging @Pkeod since it’s DefSave-related.)

Is your copy of DefSave modified? Are you using obfuscation?

I believe the answer to both of those questions is no. I don’t modify the default values for encryption and obfuscation so they are both off. The content of the save file is readable enough if I open it in a text editor:

image

Can you share an unmodified zipped copy of the settings save file from the user?

Sure thing. Thanks for looking into it.

fates_of_ort_settings.zip (1003 Bytes)

I tested loading the file directly with sys.load() and got the same error.

Can you upload a zip of a normal settings save file that works?

Here’s a file generated by my machine:

fates_of_ort_settings_working.zip (1.0 KB)

Unfortunately it is not obvious to me what is wrong, but maybe with the data samples someone on the Defold team can offer insight.

Thank you for taking the time to look at it. It’s not a showstopper because it seems to work for the user on their machine, it’s just I can’t load their save file to troubleshoot / amend their save state. I am quite confident it works for them because the error for me is logged in Err (thanks for that one too, @Pkeod) and when I asked them for error logs they said there weren’t any.

Is the user on Linux? It looks like their file has Unix (LF) while yours has Macintosh (CR). That might explain it?

We added support for negative numeric keys in the last release but that was a non breaking change.

How did you see that?

In Notepad++ on the bottom right when opening the files. Notepad++ could be been confused though, I don’t know enough about these things to say. There might be something else platform specific going on too though.

Anyone on Linux see if sys.load() loads the first sample OK without error?

1 Like

Got an answer back from the user: Win 10. I got a save file from a Linux user and was able to open it without the error. :man_shrugging:

Do you have text input in your game? What’s their system language?

I strongly recommend you setup gameanalytics for testing to get automatic script error reporting.

gameanalytics.script (1.4 KB)

2 Likes

No text input, and their system language is US English.

Good idea about automatic script error reporting, I should have thought of that myself. I’ve actually got googleanalytics implemented already, but I can’t get it to work for error reporting so I’ve got a separate thread about that.

After looking into this, it seems the saved file has become corrupted during the save.
I have a theory about how that could happen but I haven’t come up with a good way to confirm that yet.

I think this issue is actually quite serious, since it might mean that any save (under the right conditions) might get this issue.

Does you user get this issue 100%? I mean, if the user removes the save file, then saves again, will the issue come back?

I can get in touch with them to ask.

I would highlight that the user is not experiencing problems with their save. Since I obtained the file from them they have gone on to complete the game.

Could it be that you have a fallback in case the user couldn’t read the file?
How often do you save the file? Is it new data every time?
The symptom might have gone away by simply adding different data, then saving.

There’s no fallback for main save files, though on launch the settings values will revert to defaults if the file is corrupted.

Settings is saved every time the user makes changes in the settings menu. Main save files are saved frequently as well (primarily on map transitions, which happens every few minutes or so). In both cases, all values are saved every time (though I’m not sure if DefSave does something under the hood to only populate new values).

1 Like

Regarding windows, was it 32 or 64 bit?