Jump to content

Integer overflow--"bytes wasted" number is resetting to zero at 2^32


Dark Shikari

Recommended Posts

I guess you didn't anticipate "wasted" going over 2^32 did you? But after spending days trying to download from a torrent that appears to be being poisoned and finally finishing it, I have well over 4 gigabytes in hash fails... and I watched it roll over to zero and keep going.

I guess you might want to replace that with a long ;)

Also to be specific, the build is the 1.7 BETA, 1355. The number is yyyyy, as in Wasted: yyyyyy (xxxx hashfails).

Link to comment
Share on other sites

They seemed to be all over the place; utorrent was blocking clients left and right with no obvious IP pattern but it didn't seem to solve anything. Must have been a bugged torrent of some sort; I have never seen anything like it before.

It worked though in the end, after about 4.6GB of hash fails out of an 8GB download...

Link to comment
Share on other sites

Everything will rollover sooner or later :P

Only bug-proof way of doing it would be to create a list of unsigned 64-bit integers, each time an index is about to overflow, start using the next index. Total wasted is the sum of all used indexes in the list (if that makes any sense).

But I'd assume that would be a huge waste of resources.....

Link to comment
Share on other sites

Why not just let it roll over without trying to retain the exact value. Just reset it to 0 anytime it exceeds like 30000 hash fails...and maybe put a warning in the LOGGER that 'excessive hashfails' have occurred on that torrent.

Link to comment
Share on other sites

@Switeck

The number of hash fails isn't rolling over; its the total byte value.

I don't see why the user shouldn't be able to tell how much total data has been lost to hash fails; its not as if its hard to use 64-bit values. It would probably be a single change in the code assuming the variable is only declared in one place.

Link to comment
Share on other sites

Oh, then it is really silly to use such a small number. 2^32 power is only about 4 billion if UNsigned or 2 billion SIGNed. It's surprising someone didn't have this problem sooner with torrents over 100 GB in size and pieces of 4 MB (or more) each. One fast D-Link DMZ data destroyer just might set a new record hashfails in just a few hours. :lol:

EDIT: Corrected my post to correct signed/unsigned mistake.

Link to comment
Share on other sites

Well, I could replace it with a 64 bit uint, but that would eventually roll over as well (just much later...).

True, but who here has a connection that could transfer 16 exabytes in a lifetime? :D

2^32 power is only about 4 billion if signed or 2 billion unsigned.

No, it's the other way around, 4 billion unsigned, 2 billion signed (well, -2 (hence the "signed" through +2). :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...