tpatel / fortnite-replay-reader

An attempt to parse the fortnite replay files
MIT License
33 stars 10 forks source link

Out of Range Error on Windows 10 Home #4

Open peterdoyle opened 5 years ago

peterdoyle commented 5 years ago

Hi,

I have tried using these files and it works well on my mac. However on my Windows 10 pc I am getting the following errors on ;

var data = parser.parse(buffer);

buffer.js:977 throw new RangeError('Index out of range'); ^

RangeError: Index out of range at checkOffset (buffer.js:977:11) at Buffer.readInt32LE (buffer.js:1130:5) at Parser.compiled (evalmachine.:23:24) at Parser.parse (C:\Users\User\AppData\Local\FortniteGame\Saved\node_modules\binary-parser\lib\binary_parser.js:379:15) at data.chunks.data.chunks.map (C:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\lib\parser.js:204:41) at Array.map () at Object.parse (C:\Users\User\AppData\Local\FortniteGame\Saved\lib\parser.js:202:29) at FSWatcher. (C:\Users\User\AppData\Local\FortniteGame\Saved\choc2.js:39:26) at emitNone (events.js:106:13) at FSWatcher.emit (events.js:208:7)

Any suggestions? I have updated buffer.js and tried different files but they still throw the same error each time.

This is really good but just a shame with this error on my main machine.

tpatel commented 5 years ago

Hi, I feel like it's going to be hard to help given that I don't have easily access to a windows computer at the moment.

Could you try to comment the following lines and see what happens: https://github.com/tpatel/fortnite-replay-reader/blob/master/lib/parser.js#L58-L61 The reason I'm suggesting that is that it will only try to parse the header, which will help us understand if the error is in the header or in the chunks.

peterdoyle commented 5 years ago

Hi,

I commented that section out as well 202-229 and that ran through fine so I think you're right that it's to do with the chunks.

By adding back in the 58-61 and commenting out parts of 202-229 it looks like it falls over at

chunk.res = parser[chunk.ChunkType].parse(chunk.buffer);

I logged the chunk.ChunkType and chunk.SizeInBytes and they both seem to be outputting expected values. Would this indicate it's the buffer length as being an issue?

peterdoyle commented 5 years ago

Hi,

Just back from holidays and trying this again. I updated to the latest version of node and now getting a different error:

internal/buffer.js:58 throw new ERR_OUT_OF_RANGE(type || 'offset', ^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 142. Received -2011345251 at boundsError (internal/buffer.js:58:9) at Buffer.readInt32LE (internal/buffer.js:286:5) at Parser.compiled (evalmachine.:23:24) at Parser.parse (C:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\node_modules\binary-parser\lib\binary_parser.js:379:15) at data.chunks.data.chunks.map (C:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\lib\parser.js:205:41) at Array.map () at Object.parse (C:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\lib\parser.js:202:29) at FSWatcher. (C:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\choc2.js:39:26) at FSWatcher.emit (events.js:197:13) at processTicksAndRejections (internal/process/next_tick.js:74:9)

Looking around this seems to be related to handling of large ints on 64 bit systems?

Any ideas would be appreciated as this is stopping me completely.

Thanks Peter

peterdoyle commented 5 years ago

Hi,

I've tried this again on my mac as well as pc. Even on my mac some of the test files fail with the same error so I don't think this is a Windows thing.

The error is the same on each file but with a different received file. Current error is:

NodeError: The value of "offset" is out of range. It must be >= 0 and <= 142. Received -1203115368 errors.js:153 at boundsError (internal/buffer.js:58:9) at Buffer.readInt32LE (internal/buffer.js:286:5) at Parser.compiled (evalmachine.:23:24) at Parser.parse (c:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\node_modules\binary-parser\lib\binary_parser.js:379:15) at data.chunks.data.chunks.map (c:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\lib\parser.js:205:41) at Array.map () at Object.parse (c:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\lib\parser.js:202:29) at Object. (c:\Users\Bramble Lodge\AppData\Local\FortniteGame\Saved\index.js:8:19) at Module._compile (internal/modules/cjs/loader.js:796:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)

I have tried to debug through the error but can't see the issue through the Parser.Compiled stage.

If you are not looking at this any more could you let me know and I will look for another option.

Thanks

Peter

tpatel commented 5 years ago

Hi Peter, could you share the context on how you are using the library ? I did a fresh git clone, ran npm install on node v8.9.4 and it worked ok. If you have more details it would help me try to reproduce the issue on my machine. Thanks!

peterdoyle commented 5 years ago

Hi,

I am just testing the basic read of files directly in the replays folder.

Having read a bit more last night I think this may be related to a change in Node 10? Both of my machines are running on the latest release, so tried on various versions of 10 and also the 11.12.0. Not sure if you want to try on a version after 10?

I found a different issue related to out of bounds errors being caused by a change to the noAssert aspect of Buffer.readUInt32BE in Node 10:

https://github.com/PrismarineJS/prismarine-chunk/issues/40

Not sure if this is related but looks very similar?

Thanks

Peter

BattleDash commented 5 years ago

I think it's something that changed in the replays, the replays that are already in the folder work fine however new replays will give me that range error as well.

BattleDash commented 5 years ago
internal/buffer.js:53
  throw new ERR_OUT_OF_RANGE(type || 'offset',
  ^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 142. Received 204243563
    at boundsError (internal/buffer.js:53:9)
    at Buffer.readInt32LE (internal/buffer.js:275:5)
    at Parser.compiled (evalmachine.<anonymous>:23:24)
    at Parser.parse (D:\Crack\Fortnite\fortnite-replay-reader-master\node_modules\binary-parser\lib\binary_parser.js:379:15)
    at data.chunks.data.chunks.map (D:\Crack\Fortnite\fortnite-replay-reader-master\lib\parser.js:204:41)
    at Array.map (<anonymous>)
    at Object.parse (D:\Crack\Fortnite\fortnite-replay-reader-master\lib\parser.js:202:29)
    at Object.<anonymous> (D:\Crack\Fortnite\fortnite-replay-reader-master\index.js:8:19)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
peterdoyle commented 5 years ago

@BattleDashLeaks can you confirm which version of node you are trying this on as I am still getting some of the test files failing as well as newer ones?

BattleDash commented 5 years ago

v10.15.0, it works on older replays like the ones already provided in the data folder but not newer ones those give that error

tpatel commented 5 years ago

@peterdoyle I've just tried with a fresh clone on node v10.15.3 successfully. Could you try to delete the node_modules directory and run ̀npm install` again ?

@BattleDashLeaks if you have new replays you're ok to share, feel free to send them so I can update the library ;)

BattleDash commented 5 years ago

@tpatel a compressed and decompressed replay from v8.20

Can't reveal the method to decompress them but it's not hard

https://staging.battledash.co/resources/DecompressedReplay.replay https://staging.battledash.co/resources/CompressedReplay.replay

peterdoyle commented 5 years ago

Hi @tpatel I have removed and npm installed. I still get the same issue on all the replays. But I'm still getting it on the ones from your project as well.

The test and test 2 also fail as well. The other three pass. So I don't think this is a new / old version issue. But I may be wrong.

BattleDash commented 5 years ago

Might have found the root cause, if you comment out from line 204 to 226 in parser.js the code runs successfully but doesn't include any eliminations

    /*chunk.res = parser[chunk.ChunkType].parse(chunk.buffer);

    if(chunk.res.metadata == 'AthenaMatchTeamStats') {
      chunk.res.res = parser.MatchTeamStats.parse(chunk.res.buffer);
      delete chunk.res.buffer;
    } else if(chunk.res.metadata == 'AthenaMatchStats') {
      chunk.res.res = parser.MatchStats.parse(chunk.res.buffer);
      delete chunk.res.buffer;
    } else if(chunk.res.group == 'playerElim') {
      chunk.res.res = parser.PlayerElim.parse(chunk.res.buffer);
      delete chunk.res.buffer;
      delete chunk.res.res.a_length;
      delete chunk.res.res.b_length;
    } else if(chunk.res.group == 'checkpoint' && chunk.res.buffer) {
      chunk.res.res = parser.CheckpointHeader.parse(chunk.res.buffer);
    }

    if(chunk.res.buffer && chunk.res.buffer.length === 0) {
      delete chunk.res.buffer;
    }
    if(chunk.res.buffer) {
      chunk.res.buffer = chunk.res.buffer.length;
    }*/
BattleDash commented 5 years ago

it's caused by chunk.res = parser[chunk.ChunkType].parse(chunk.buffer);

peterdoyle commented 5 years ago

@BattleDashLeaks if you look above I pointed to that previously, it's to do with the length of buffer I think. Just got find why it is seeing longer buffer lengths than expected now.

BattleDash commented 5 years ago

hmm yeah I don't know

BattleDash commented 5 years ago

Found something, apparently in node v10.0.0+ unsigned 64 big endian integers aren't supported. You can get around using https://www.npmjs.com/package/int64-buffer apparently but I wouldn't know how to implement it into this

tpatel commented 5 years ago

Thanks for the help guys, I'll try to look into that in the next couple of days hopefully 🙏

BattleDash commented 5 years ago

Thanks for the help guys, I'll try to look into that in the next couple of days hopefully 🙏

Thanks! Hopefully you can figure it out

tpatel commented 5 years ago

I've just pushed a fix that prevents a parsing error in the Header (it was failing with the latest replay format): I've removed a bit of code that was reading unknown information.

@BattleDashLeaks regarding the decompression method, I think I'm aware of it, can you just confirm it's a proprietary compression algorithm ?

BattleDash commented 5 years ago

I wouldn't say it's proprietary, Replays use Oodle compression. You can make a decompressor for it relatively easily using https://github.com/Crauzer/OodleSharp

peterdoyle commented 5 years ago

Hi @tpatel just run a couple of tests and that seems to be working great with my latest demos.

Will be having a play this week and let you know if anything else comes up

Thanks a lot for help

mtnair commented 5 years ago
$ node index.js
internal/buffer.js:49
  throw new ERR_OUT_OF_RANGE(type || 'offset',
  ^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 122. Received 4294967345
    at boundsError (internal/buffer.js:49:9)
    at Buffer.readInt32LE (internal/buffer.js:271:5)
    at Parser.compiled (evalmachine.<anonymous>:21:24)
    at Parser.parse (D:\Benutzer\Martin\Documents\Projekte\Sonstige\FortniteReplayParser\fortnite-replay-reader\node_modules\binary-parser\lib\binary_parser.js:379:15)
    at data.chunks.data.chunks.map (D:\Benutzer\Martin\Documents\Projekte\Sonstige\FortniteReplayParser\fortnite-replay-reader\lib\parser.js:207:41)
    at Array.map (<anonymous>)
    at Object.parse (D:\Benutzer\Martin\Documents\Projekte\Sonstige\FortniteReplayParser\fortnite-replay-reader\lib\parser.js:196:29)
    at Object.<anonymous> (D:\Benutzer\Martin\Documents\Projekte\Sonstige\FortniteReplayParser\fortnite-replay-reader\index.js:8:19)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)

I think it's broken again, it doesn't work with current replay files. Older files like in the repo included are working.

XeraFiu-YTB commented 4 years ago

On Window 7 with Node v12.16.2 it doesn't work... RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 124. Received 3215298567

It's seems that this error appeared at line 207 : chunk.res.res = parser.PlayerElim.parse(chunk.res.buffer);

Any answer will be helpful thx :page_with_curl: