29
2
We all know how the discussion about which is the best operating system caused a lot of flame-wars. Your goal is now, to provide decisive "proof" that your favorite operating system is better... ah, no, much better, to provide decisive "proof" that another operating system is bad.
The task: Write a program, that does some calculations, and it works correctly on at least one OS and incorrectly on at least another one.
- the program should do at least some calculations, so it has to read some simple input (preferably on the standard input, or if from files if you want, but misusing little endian/big endian would not only be cheap, but also obvious), and provide some output depending on the input. The calculations should be meaningful and justified, for example solving a real life or a mathematical problem.
- you should specify both operating systems, stating on which one it will work correctly, and on which one it won't. Both operating systems should be well known, and from roughly the same time (so no DOS 1.0 versus a modern OS). It is advised to provide a short description about the cause of the difference (especially if you suspect many people would not realize it) in spoiler tags.
like this
the cause of the difference has to be subtle, so no
#ifdef _WIN32
or similar, please! Remember, your goal is to "prove" that this specific system is bad, so people should not be able to (immediately) spot your trick!if there is a very strange or very unusual part in your code, you have to justify it in comments why it is there. Of course, this "justification" can/will be a big lie.
Scoring:
This is not a golf! The code should be well organized, and kept simple. Remember, your goal is to hide a bug into it so that people won't suspect it. The simpler the code, the less suspicious it is.
The winner will be decided by votes. The most votes after approximately 10 days after the first valid submission wins. Generally, answers where the code is easy to read and understand, yet the bug is well hidden, and even if discovered, can be attributed to a mistake rather than malice, should be voted up. Similarly, it should be worth much more if the bug just causes an incorrect result, rather than just causing the program to crash or to not do anything.
As usual, I withhold the right to choose an answer as a winner if it is not more than either 10% or 1 point below the one with the most votes, on any subjective criteria.
5Interestingly
make (1)
works properly on essentially every unix box and improperly some windows boxes. Not because of the OSes, but because of the filesystems. Any filesystem that keeps file modification dates to low precision may fail tomake
properly on a fast machine. – dmckee --- ex-moderator kitten – 2012-07-18T17:11:02.7101@dmckee: this is why I'm glad that I did not leave everything open, and you have to read in some input and do some simple calculations. – vsz – 2012-07-18T17:58:10.167
That is my point:
– dmckee --- ex-moderator kitten – 2012-07-18T18:24:54.777make
does read input and do some calculations (and interact with the filesystem and launch other processes). These types of programs exist in the real world.Here is one that works in openbsd but not linux http://stackoverflow.com/a/2455223/174728
– gnibbler – 2012-07-18T22:09:21.76710I only figured it now, that this quest for evil code has the Id of 6666 – vsz – 2012-07-19T15:46:14.867
3Here's to hoping for an answer that works on Windows and <Insert Linux Distribution>, but not on Mac. – Casey Kuball – 2012-07-26T02:03:06.100
@dmckee: NTFS has I think a 100 ns resolution, so wouldn't that be only if you're running off an old FAT disk? – Mechanical snail – 2012-08-01T09:45:20.550
1
I'm voting to close this question as off-topic because underhanded challenges are no longer on-topic on this site. http://meta.codegolf.stackexchange.com/a/8326/20469
– cat – 2016-04-18T12:42:22.257Just write a program that uses all of the system's memory minus about 20mb, then FreeBSD will run it and Windows and some Linuxes won't. :D – cjfaure – 2014-01-24T15:29:35.317
One idea might be to use IntPtr.Size, because that's 8 on 64 bit machines, but 4 on 32 bit machines. However, it depends on how you compile your code, and 64 bit applications won't run on 32 bit machines. – Nzall – 2014-06-18T13:34:23.393