Fenixin / Minecraft-Region-Fixer

Python script to fix some of the problems of the Minecraft save files (region files, *.mca).
GNU General Public License v3.0
543 stars 101 forks source link

Exception:<class 'ValueError'>read length must be non-negative or -1 #145

Open SwiftWinds opened 3 years ago

SwiftWinds commented 3 years ago

While trying to run this on my corrupt MC Eternal world, I get this error:

Bug report:

**********
*** Exception while scanning:
*** taiga_meteors.dat
**********
*** Printing the child's traceback:
*** Exception:<class 'ValueError'>read length must be non-negative or -1
**********
*** File /home/matt/server/Minecraft-Region-Fixer/regionfixer_core/scan.py, line 746, in scan_data
***   _ = nbt.NBTFile(filename=s.path)**********
*** File /home/matt/server/Minecraft-Region-Fixer/nbt/nbt.py, line 628, in __init__
***   self.parse_file()**********
*** File /home/matt/server/Minecraft-Region-Fixer/nbt/nbt.py, line 655, in parse_file
***   self._parse_buffer(self.file)**********
*** File /home/matt/server/Minecraft-Region-Fixer/nbt/nbt.py, line 493, in _parse_buffer
***   tag._parse_buffer(buffer)**********
*** File /home/matt/server/Minecraft-Region-Fixer/nbt/nbt.py, line 493, in _parse_buffer
***   tag._parse_buffer(buffer)**********
*** File /home/matt/server/Minecraft-Region-Fixer/nbt/nbt.py, line 350, in _parse_buffer
***   read = buffer.read(length.value)**********
*** File /usr/lib/python3.7/gzip.py, line 276, in read
***   return self._buffer.read(size)
**********

The command I ran was:

python3 regionfixer.py -p 4 ../world --rc --rw --dc --dw --ds --backups /home/matt/server/backups/world/Backup--world--2020-12-18--06-47,/home/matt/server/backups/world/Backup--world--2020-12-18--02-06,/home/matt/server/backups/world/Backup--world--2020-12-18--01-24,/home/matt/server/backups/world/Backup--world--2020-12-18--00-24,/home/matt/server/backups/world/Backup--world--2020-12-17--23-24,/home/matt/server/backups/world/Backup--world--2020-12-17--22-24,/home/matt/server/backups/world/Backup--world--2020-12-17--21-24,/home/matt/server/backups/world/Backup--world--2020-12-01--04-24,/home/matt/server/backups/world/Backup--world--2020-12-01--03-24,/home/matt/server/backups/world/Backup--world--2020-12-01--02-24,/home/matt/server/backups/world/Backup--world--2020-11-28--08-17 -v

I really appreciate any help you can provide. :)

SwiftWinds commented 3 years ago

Current workaround is to move DIM7/data/taiga_meteors.dat, data/taiga_meteors.dat, The_Beneath/data/taiga_meteors.dat out of the world folder, run regionfixer, then move them back in.

SwiftWinds commented 3 years ago

Here is a copy of the taiga_meteors files: taiga_meteors_files.zip

Fenixin commented 3 years ago

Hello!

Sorry for the late answer, the end of term it's a pretty busy time for me.

I've got the file and I confirm this is a bug in region fixer. Will look into it when I get some time. Thanks for the report and the files.

Anyway, it's probably too late but from the crash report I think that the file is lost because it's a compressed file and it seems the length of it is -1. That means is corrupted and most probably you can't get anything from it. So, if I'm right, removing it is the only solution.

SwiftWinds commented 3 years ago

Sorry for the late answer, the end of term it's a pretty busy time for me.

Oh yeah, that's no problem. Thanks for getting back to me!

Anyway, it's probably too late but from the crash report I think that the file is lost because it's a compressed file and it seems the length of it is -1. That means is corrupted and most probably you can't get anything from it. So, if I'm right, removing it is the only solution.

Hmm... I see. As I said before, I moved the taiga_meteors files out, ran regionfixer, and moved them back in. Everything still works, and it seems that two of the taiga_meteors.dat files changed (their hashes are now different), and AFAIK, the world is not currently corrupt (although I can run regionfixer to double-check), so some mod is definitely using it.

Feel free to close this issue if you feel that the workaround I described is sufficient. Otherwise, maybe regionfixer could be amended to skip over such corrupt files or perhaps even prompt users to delete them? I can also run tests/send files that would help you solve the issue.

Thanks!

Fenixin commented 3 years ago

As I said, AFAIK the files taiga_meteors.dat are corrupted. But I will give this a better look later, thanks for the report. If they are really corrupted region-fixer should detect them and, at least, report them.

I will leave this open as a remainder