- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Looks more like an excrement function than an increment function.
Admin
Admin
Admin
Is ParanoiaOverflow.com part of the StackExchange network?
Admin
We've got a kill screen coming up everyone! Kill screen everyone! Kill screen!
Admin
Admin
Linux does this - I believe its jiffies counter is set to about 2 minutes before wrapping around (if there's not a setting to adjust how long you have until it wraps) for this very purpose (because the counter typically takes a long time to wrap, but not long enough that a stable system wouldn't encounter it).
Admin
The code is actually counting "seconds", i.e., second helpings passed out. The target audience being indvidual bacteria, it's quite possible for this to overflow.
Admin
Exactly my point!
Admin
So, if you want to know the date, you have to include the leap year exceptions at every 100 years, along with the exception exceptions at every 400 years.
Admin
It's probably more like "u long, bro?" but without the coder getting a sexual harassment suit from his boss.
Admin
Thought the same thing :
Double WTF possible
Admin
I kid you not...
Inserting random bit errors in memory was part of the 'official' static discharge robustness testing procedure for embedded devices at one of the companies I used to work at.
Admin
You should be catching the more specific SpaceTimeContimuumException rather than just Exception. That's best practice.
Admin
What happens when totalOverflows overflows?
Admin
Admin
That's the wrong calendar. The world moved on to Gregorian, during Pope Gregory XIII's reign. That was nearly 500 years ago.
Admin
She said I was long enough, but we added seconds and I overflowed.
Admin
You may look at
and convince yourself that you know what will happen; I prefer to avoid potentially expensive surprises.
-Harrow.
Admin
[*] That's 441 (not quite) years ago, far enough from 500 for "nearly 500 years ago" to be a questionable use of "nearly". Well, I'm questioning it, anyway. I would, however, accept "nearly 450".
Overall, then, you'd be better off saying that the world "began moving on to Gergorian during the reign of Pope Gregory XIII. That was nearly 450 years ago."
Addendum (2013-03-06 03:46): Oops, arithmetic failure. 431 years ago. Sorry.
Admin
Signed overflow is detected by a difference in the carry in and out of the highest bit of the operation, and sets the "overflow" flag in the CPU's status word. x86 (and presumably x64, not tried) has an instruction "INTO" that generates a specific software trap if the overflow flag is set.
MSDOS would, by default, catch this trap, print a message, and abort the program. I'd imagine that Windows will redirect it into a SEH exception, although possibly not one that the C/C++ runtime will convert into something useful, and (on VC6+) it will therefore be caught only by catch(...) blocks (so you can't tell what happened).
But most compilers won't insert code to fire this trap, so it isn't going to happen.
Admin
So did you develop any "design patterns" and "best practices" like this: const int a = 5; assert(a == 5); // computations assert(a == 5); // just to be certain
Also, if you can't trust RAM, why do you trust ALU? bool canTrustALU() { return ((5 * 3 == 5 + 5 + 5) && (18 / 3 == 2 * 3)); }
What I mean is that unless you program for a hardware that runs in harsh environment (e.g. in places with lots of radiation) memory corruptions should be fixed (as they are most likely caused by dangling pointers, etc.) rather than worked around.
Admin
My guess is that it was done this way because some linting tool issued a warning of possible overflow on the ++.
Linting tools are a very useful item, but blindly following everything they say isn't always the best option.
[captchas .... you know they're weak when the browser's autosuggest feature guesses the right word as soon as you start typing]
Admin
Seriously, your dealing with overflows? I told my manager I need a 1024-bit architecture and whenever something overflows I say: "Hey, I said so. This bug occurs because you did not buy the hardware I asked for!"
Admin
Perl's gmtime() will output nothing if the year is greater than 0x7fffffff.
Admin
Which is precisely why I didn't specify a date. I specified a number of years, which is different. That's why I said "584,542,046,091 years" and not "584,542,048,104 AD". Dates beyond 5 - 6 billion years from now are entirely useless due to the red giant phase of the sun, so I did not use them. I used the standard astronomical year, which has nothing whatsoever to do with a calendar year.
As for the other calculation I used, 35,096,545,043,317 AD is still going to be closer to 2^70 seconds regardless of what arbitrary earth-centric calendar year you choose to use. Even if you choose to say that the year is 365.242 days long, or 365.242154861484384 days long, it does not matter because the value of the highest order of magnitude hasn't changed.
You could say that a year is 30,000,000 seconds and that the date is 30,000,000,000,000, or you could say that a year is 39,999,999 seconds and the date is 39,999,999,999,999 and you're still close to 2^70:
30,000,000 * 30,000,000,000,000 = 9 * 10^20 log(9 * 10^20)/log(2) ~= 69.61
39,999,999 * 39,999,999,999,999= 1.6 * 10^21 log(1.6 * 10^21)/log(2) ~= 70.42
So, yes, as long as a year is roughly 300-399 days, 35,096,545,043,317 AD is about 2^70 seconds away.
Admin
Yes, but I live in the former British North American colonies, and we didn't switch over until 1752. You can hardly expect us to have everything updated for such a recent change.
Admin
Now that I think about it, who says the Gregorian calendar is "right" and the Julian calendar is "wrong"? A Gregorian year more nearly approximates the amount of time it takes the Earth to go around the sun, but who says that that's the criteria? Arguably a simpler calendar is "better" even if it does not match an astronomical year as closely.
And isn't it rather culturally chauvinistic to use a European calendar? Why not the Islamic calendar? Millions of people in the world use that, and its months more nearly approximate an astronomical month than Gregorian or Julian months do.
To say that the Gregorian calendar is 500 years newer seems like a rather trivial number when we are talking of a time scale of billions or trillions of years.
Admin
Some systems test if two (or five) CPUs agree on the result of a computation. When they don't all agree, they delay the space shuttle, or they repeat the computation or they try a fallback route. Sometimes it turns out that the space shuttle was delayed because of a software bug, but even so, the comparison tests serve their purpose.
Some of the giants of the industry figured out how to get reliable results on unreliable hardware in the 1940's. Too bad that technology has been lost.
Admin
Admin
Somehow I doubt that genuine RAM failures are common. I rather think that the tools like memtest86 are only used by overclockers who want to know how many more Hz they can squeeze of the hardware. Of course I did not do any Internet-wide survey to confirm this...
I agree that redundancy and robustness in mission-critical systems is, well, critical, and it is better to err on the safe side (e.g. delay the launch). This is also where all the hardware tools like watchdogs and brownout detectors come from and where special checks in software are needed. However, badly soldered HW is not a good reason to add paranoia to SW.
Admin
If it's a signed long, it will always be less than ulong.max_avlue.
Admin
Admin
While the situation it is guarding against is unlikely, this code isn't really a WTF. I'd rather see an unnecessary guards due to a paranoid programmer than no guards at all.
Admin
I don't think this will work at all. When the value overflows it will become negative, and still be less than max long value.
Admin
In my experience HW (solid state, I'm not talking about mechanical parts) is orders of magnitude more reliable than SW. What are the chances that a company doing sloppy job soldering HW can excell at SW?
Admin
Some are office machines used by me or co-workers, some are owned by myself, some are owned by friends who know I have computer experience, etc.
I suppose that out of 200 machines I've seen bad RAM on 10. I've seen bad CPUs on 0 (no estimation needed for this 0). I've seen bad hard drives on around 10 and bad graphics chips on around 3. Yup. Along with firing anyone who dares to propose quality checks.Admin
If you're gonna do it, do it right.
Admin
TRWTF is that if _totalSeconds really was ulong.MaxValue, and it was incremented by 1, it would automatically be 0 because arithmetic is modulus. This entire if statement is redundant.
...
Although, in some interpreted languages, it would just stay at ulong.MaxValue.
And in some managed languages, it would throw an exception.
But in those cases, it's safe to say that those evil languages are TRWTF.