The importance of error code backwards compatibility

Date:January 18, 2005 / year-entry #16
Tags:history
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20050118-00/?p=36673
Comments:    83
Summary:I remember a bug report that came on in an old MS-DOS program (from a company that is still in business so don't ask me to identify them) that attempted to open the file "". That's the file with no name. This returned error 2 (file not found). But the program didn't check the error...

I remember a bug report that came on in an old MS-DOS program (from a company that is still in business so don't ask me to identify them) that attempted to open the file "". That's the file with no name.

This returned error 2 (file not found). But the program didn't check the error code and though that 2 was the file handle. It then began writing data to handle 2, which ended up going to the screen because handle 2 is the standard error handle, which by default goes to the screen.

It so happened that this program wanted to print the message to the screen anyway.

In other words, this program worked completely by accident.

Due to various changes to the installable file system in Windows 95, the error code for attempting to open the null file changed from 2 (file not found) to 3 (path not found) as a side-effect.

Watch what happens.

The program tries to open the file "". Now it gets error 3 back. It mistakenly treats the 3 as a file handle and writes to it.

What is handle 3?

The standard MS-DOS file handles are as follows:

handle name meaning
0 stdin standard input
1 stdout standard output
2 stderr standard error
3 stdaux standard auxiliary (serial port)
4 stdprn standard printer

What happens when the program writes to handle 3?

It tries to write to the serial port.

Most computers don't have anything hooked up to the serial port. The write hangs.

Result: Dead program.

The file system folks had to tweak their parameter validation so they returned error 2 in this case.


Comments (83)
  1. AC says:

    And that, folks, shows the importance of type checking in compilers – don’t use something that isn’t a handle as a handle!

  2. Superman says:

    More like the importance of defining error based constants am i rite

  3. fopen says:

    fopen("","") crashes exe-process. Is this correct?

  4. John Topley says:

    How did the file system folks know that they had to tweak their parameter validation – was the application already on the list of programs that were used to test Windows 95? If not, how did it get added? The wider question is: how do Microsoft keep on top of all this stuff?

  5. Arta says:

    I’ve wondered that too, along with: How popular does a program have to be before Microsoft tweak Windows to stop it breaking?

  6. mschaef says:

    This is another broader question, but how where is all this special case logic represented in the code? Is there a if(…) statement that explicitly checks for this case and returns 2?

    If so, how do you keep all that straight? Sounds daunting to me.

  7. Raymond Chen says:

    "How popular does a program have to be before Microsoft tweak Windows to stop it breaking?"

    A program’s popularity is just one factor in deciding how a particular problem should be addressed. It’s not like there’s a "if the program has more than X copies, we must fix it" rule.

  8. Peter da Silva says:

    This is why I use a Mac.

  9. Frederik Slijkerman says:

    "This is why I use a Mac."

    No, they just let everything crash…

  10. Raymond Chen says:

    Peter da Silva: Can you be more specific what you mean by "this"? Is it that the Mac doesn’t have buggy programs? That the Mac API makes it harder to make mistakes like this? That Apple treats buggy programs differently from Microsoft?

  11. Mike Dahmus says:

    Stuart,

    Actually there’s a more general solution – use strongly typed languages. As the first commenter pointed out, if you couldn’t convert from (int) to (handle) without using a library routine of some kind, this particular error couldn’t happen. No exception necessary in this case – C/ASM (whichever it was) itself is mostly to blame.

  12. Olivier says:

    I think the program didn’t check the error code on purpose and simply abused the behaviour of the function so the "file open" code could also be used to "open" stdout just like any other file by specifying "".

    This is similar to a recent enough posting ( http://weblogs.asp.net/oldnewthing/archive/2004/12/15/313250.aspx ) where faulting on an invalid instruction was used to switch to kernel mode, because it was faster.

  13. Miles Archer says:

    If there ever was a case to patch the offending program rather than to change the OS, this has got to be it.

  14. Pete King says:

    Lets just hope that Windows always recognises that program 100% of the time and never makes any mistakes… or some other programmers are going to think that this is some weird bug in windows when it happens to them…

  15. Raymond Chen says:

    "If there ever was a case to patch the offending program rather than to change the OS, this has got to be it."

    On the other hand, this program may have merely been the "tip of the iceberg". Who knows how many other programs were also relying on specific error codes – this just happened to be the first one found. The others, nobody talks about because by the time they were tested, the fix was already in.

    (Note: As I already noted, this was an MS-DOS-based program. The MS-DOS API is asm-based.)

  16. stupid says:

    Oh my god. Why does Microsoft support very stupid programmers?

  17. Cooney says:

    <Unix bigot>That’s why error codes should be negative.

    Miles: wouldn’t it be nice if we could patch the programmer?

  18. "Oh my god. Why does Microsoft support very stupid programmers?"

    Because people buy programs from stupid programmers, and they want their programs to keep working in new versions of Windows.

  19. Scott says:

    For Peter De Silva re: Mac

    Ric Schaut had an interesting post a while back on a bug in MacWord that had to do with Mac file open limits.

    http://blogs.msdn.com/rick_schaut/archive/2004/05/19/135315.aspx

  20. K Biel says:

    >"This is why I use a Mac."

    >>No, they just let everything crash…

    But the crashes have a cute little bomb icon that makes it OK.

  21. Eric Newton says:

    Yeah, I still use Lotus 1-2-3 dos version on windows XP. Now thats progress. Can you feel the sarcasm?

  22. Raymond,

    I have generally almost always supported your point of view in your posts. But even I am coming to the point to where I must say there are times when MS should have told some of these companies that put out bad software where to stick it.

    Regards,

    James Summerlin

  23. Daniel says:

    I think that "not testing error codes" and "changing error codes" are two different problems.

    Actually I find that error code 2 (file not found) makes more sense than error code 3 (path not found) in this case, since there isn’t an error code for invalid file name.

    Not knowing the details about the offending code, that may have beem burried in a third part library or whatever, I would give the programmer the benefit of doubt. Specially when I try to think how to detect such an error (the program was working when it was tested!).

    Last, someone mentioned Lotus 1-2-3. When DOS moved from version 1 to 2, the Lotus copy protection code was broken (something related to timing and out of Microsoft control, I believe). Anyway, guess who was blamed?

    Daniel

  24. autist0r says:

    Yes but what if the company is dead ? Problem is that "software works thanks to a miracle" => "new Os is out" => "software doesn’t work anymore" => microsoft fault…

    suxx but you have to fix other people mistakes :(

  25. Dennis Forbes says:

    Why would a function return an error code that collided with seemingly valid values (e.g. error code 2 that is also a valid file handle)? This seems to be more of a error namespace issue than an error checking problem.

    I’d give the ISV the benefit of the doubt – the documentation isn’t all there (obviously it is for the standard I/O functions, but I mean as a general rule developers sometimes need to rely upon behaviour discovery to interoperate with the system APIs), and if someone opened a no-name file and discovered that gave them effectively stdout, through the discovery process they would consider this a fact -> no name files = stdout.

  26. G. Man says:

    Macs don’t have anything to be backwards compatible to. All Mac software is dead or dying already, except itunes. Therefore, Mac OS does not have this problem.

  27. Muck says:

    G. Man: Ha, ha.

    The effort that Raymond and others at Microsoft make to ensure backwards compatibility is probably good for Windows as a platform… although I guess private users don’t benefit from this as much as home users.

    The only DOS software that I would like to run is some classic games. Most of which won’t run for reasons entirely outside of Microsoft’s control (too fast processors etc).

  28. Jerry Pisk says:

    Muck, the effort to keep buggy programs might be good in the short term but in the long term it will simply create a generation of ignorant programmers that write code that has issues. Most of the time those directly translate to security issues. That’s why Windows programs are buggy and insecure, because Microsoft creates and supports that culture of writing simple, broken, don’t need to fix anything code. But it’s a two edged sword, you will get more programs but they’ll be lower quality.

  29. autist0r says:

    The only purpose of an OS is to run programs. No program is perfect. Enforcing error-less programs is just not going to work. Making tools to help developpers to make error-less programs is IMHO, the way to go. Plus, don’t forget we made a lot of progress in software engineering lately : it’s easy to bash a 5 years old program, and I think there is still a very good margin for progression. Just try to run BoundChecker or Valgrind or anything on your programs and tell me if they all pass. ;)

    MMmm btw if you think user apps are buggy, just have a look at drivers and see how many just do stuff they shouldn’t. :) I can’t imagine how many evil buffer overflows are lurking around in my system… :(

  30. Cooney says:

    G. Man: Apple is dying, film at 11.

    I don’t know what hacks exist for it, but I still run some old software on XP. Civ2 f’rinstance – it’s one of the first CD games I bought, the video codec is no longer supported, but I like it just fine. I’m currently playing the Chinese, planning to invade and decimate the Sioux.

  31. mschaef says:

    "Last, someone mentioned Lotus 1-2-3. When DOS moved from version 1 to 2, the Lotus copy protection code was broken (something related to timing and out of Microsoft control, I believe). Anyway, guess who was blamed? "

    Lotus took a lot of heat for its stupid copy protection anwyay.

  32. camillo says:

    The first goal of a company is to make money and it seems to me that Microsoft is succesfully doing this. Probably their strategies are not so bad…

  33. After your recent post advocating error code returns over exceptions, I just have to point out that this situation is a good example of the kind of thing that can’t ever go wrong in an exception-based environment…

    (Yes, plenty of other things *can* go wrong, with both exceptions and error codes. But the irony of the juxtaposition of the two posts spoke to me…)

  34. James Day says:

    Even capable people write bugs. When customers have mission-critical systems which break because of an unfortunate interaction of an undiscovered bug and a new operating system, Microsoft can find itself in the position of having a significant customer who can’t afford to switch OS because of that bug. That gives Microsoft an incentive to fix it if the original company can’t or won’t. Can’t can happen if the other company has only compiled versions of a critical library which has the bug and can’t get a fix from their supplier because that supplier is out of business or unwilling.

    Open source tools are one of the better protective measures against his sort of unfurtunate situation – you have at least some chance of being able to fix the mess yourself. Choosing vendors who provide product lifetimes spanning the real life of mission critical systems (10-40 years) also helps. Micorosoft doesn’t but the often thankless backwards compatibility work helps it to come much closer.

  35. Tim Smith says:

    Raymond’s example does apply to exceptions, but in a slightly different manner. Exceptions just as return codes create a contract between the API creator and the consumer. If new exceptions are added, then depending on how the program handled the old exceptions, the new version of the API could produce unexpected results in the application.

    In this case, you are too focused on the specifics of the issue and missing the bigger picture.

  36. Tim Smith says:

    It is VERY common in mission critical systems that source code is kept in escrow to protect against the supplier being unable to support the software. Open source is just another method of handling the same problem.

  37. I believe one technique that Apple employs today is version link backwards compatible goo to certain versions of apps and then they notify the developer of the problem and let them know that their next release needs to fix it because the version-link goo won’t help it otherwise.

    There are a couple of ways Apple can do this, including keying of what version of the OS the app was linked against.

    Seems like a nice compromise: they ‘encourage’ ISVs to do the right thing while not causing too much harm to the users of those apps.

  38. Leif says:

    How did this myth start that Apple doesn’t take backwards compatibility seriously? This myth that when the latest version of Mac OS breaks your app, Apple’s attitude is, "tough luck, buddy — fix your app"?

    With Mac OS X, Apple has made a relatively clean break with the past. But the entire history of Mac OS up until that point was a struggle to enhance the OS while breaking as few apps as possible. They employed much of the same ugly hacks that I love reading about here on Raymond’s blog. That’s all that classic Mac OS *is*: one big heap of backwards-compatible goo. When apps did break, I’d assume that they had no other choice.

    Example: I attempted to reverse-engineer MultiFinder once. There is code in there that literally says the following:

    if (app == ‘abcd’)

    /* do something */

    where ‘abcd’ is the signature of a certain app. Ironically, they even had to do this with certain ill-behaved Microsoft applications. :-) Ditto for the earlier "Switcher" (see quote below).

    Thankfully, most of Mac OS’s error codes are negative… :-)

    –Leif

    "Predictably, the hardest part of finishing Switcher was making it work smoothly with the Microsoft applications."

    –Andy Hertzfeld

    http://www.folklore.org/StoryView.py?project=Macintosh&story=Switcher.txt

  39. Philip says:

    Lief wrote:

    [quote]

    Example: I attempted to reverse-engineer MultiFinder once. There is code in there that literally says the following:

    if (app == ‘abcd’)

    /* do something */

    where ‘abcd’ is the signature of a certain app. Ironically, they even had to do this with certain ill-behaved Microsoft applications. :-) Ditto for the earlier "Switcher" (see quote below).

    [endquote]

    One example of this in Windows is with the LoadLibrary API — there is special handling for an application requesting to load TWAIN32.DLL.

  40. Anonymous says:

    lazybones &raquo; Compatibility

  41. kito says:

    A most likely impossible ATM but nice thought for the future fix would be to make windows more configurable. Because having all these BC fixes is only useful to the minority, but when you’re in that minority it really sucks. It’d be nice to have compile-on-demand copies of windows.

    Say, you go to microsoft.com, fill out a questionaire of what prehitoric apps you plan on using, and then a server compiles you a custom copy of windows, based on a complex set of #if statements and the like. How often does someone install a buggy app from back in 1985 out of the blue for the first time while running XP? If they do, then its time to DL a new build of windows. if not, they’ll be saved from some BC mush.

    Again, this is something that open source would provide an alternate solution, but I dont think anyone’s though of a profitable open-source business model that MS could use.

  42. Raymond Chen says:

    … even if there were only ten yes/no questions, that would be 1024 versions of Windows, most of which were never tested. (And then if a patch comes out, you end up with 1024 different patches… most of which were never tested…)

  43. froz says:

    Quick response to Peter da Silva-

    I developed code for OSX for a short period of time, mostly during the 10.2 timeline. Even though the code was pre-alpha it was not uncommon to have it break after an update.

    Quick searches on Google for ‘10.2.2’, ‘10.2.3’, ‘10.2.4’ bring up mentions of broken applications and patched apps for the latest OS update. A few samples, all grabbed off the first page of Google for 10.2.x searches.

    http://www.webweavertech.com/ovidiu/weblog/archives/000098.html

    http://radio.userland.com/appDownloads/809b1

    http://docs.info.apple.com/article.html?artnum=107669

    My experience is that there is a lot of trepidation in installing the latest Mac updates in the Mac community for precisely these reasons.

    I’m amazed at the extent to which hacks are put into the OS to support bad code. In the end I too just want my apps to work after and update. Thanks Raymond.

  44. Aaargh! says:

    If it’s bad code, you should not support it, instead the bad code should be fixed, period.

    If it can’t be fixed, it breaks, too bad.

    The big problem with Microsoft is that it is a corporation, they do not want to do the Right Thing(tm), but the most profitable thing.

    Eventually all these marketing-inspired hacks will result in a unmanagable mess.

  45. Moi says:

    I’ve just written a program which misuses a feature of Windows. To whom do I have to write in order to get future versions of Windows changed so that they don’t mess up my program?

  46. Paul Spendlove says:

    For those bashing MS for app-compatibility hacks, even insisting that people fix their broken apps when they probably don’t even have the source code (we’re talking legacy here) – you’re betraying a certain mind-set of the software as being more important than the processes that it is designed to support.

    But I’d say that this is not an inappropriate attitude, because software is a means, not an end. It exists to allow people to do things in the real world. So anyone complaining that a hack that actually enables people to get on and do things is somehow wrong purely because it is ugly from a coding viewpoint has things precisely backwards! I talk as one of the most anal people in my entire company about software testing and process improvement. I stop people from hacking all the time. But there comes a point where you hold your nose and do the thing which, for a whole bunch of messy reasons, is a greasy hack, but is the best thing to do in the real world where we all live.

    As and when OSS ever gets the same level of market penetration as Microsoft, they will face precisely the same problems. The real world is messy and complicated, and doesn’t fit neatly into statically analyzed systems, thank goodness.

  47. Paul Spendlove says:

    "not an inappropriate attitude" -> "not an appropriate attitude" -> "mistaken"

    Serves me right for getting all verbose.

  48. Moi says:

    you’re betraying a certain mind-set of the software as being more important than the processes that it is designed to support

    No. "The software" will continue to support "the process" running on the old operating system. Software doesn’t degrade over time. However MS wants you to buy Windows Whatever, and that is why they make it an issue. They really don’t want you continuing to run Lotus 1-2-3 DOS on DOS, even though it runs perfectly happily there; they would much rather you ran it on "New! Improved!" Windows Whatever, because that’s another few dollars in their bank account rather than yours.

  49. Fouad says:

    Its Funny to notice the differing viewpoints on this board. I read this blog every single day, and I am in the IT Industry (Network Admin) and definalty not a programmer worth my salt.

    I notice that when people MS bash, they come at the view point as programmers. Sometimes I see a kind of "Righteous" attitude when it comes to programming from a programmers eyes.

    I think bottom line, IT as a whole is useless as an End, its only a means to an end. Its a tool that you can use to make your lives better and companies more profitible; If you know how to use it.

    In the real world, if it takes the Ugly Hacks to make things workable in the real world, then that IS a part of the art of programming. We don’t live in an ideal perfect world where all the code is perfect. Just doesn’t make sense, people need programs to do their jobs and go home. To argue against that is useless IMHO.

  50. John Topley says:

    "There’s two different viewpoints here:

    1) Writing code is a means for a corporation to generate profit.

    2) A corporation/profit is a way to finance the coding."

    For corporations, coding is a means to an end. They are ultimately accountable to their shareholders and that means that 1) above holds true.

  51. John Topley says:

    "It’s the same as with music. A commercial artist like Britney Spears may be more profitable than e.g. Mark Knopfler, but the latter makes way better music."

    You say that as if it’s an objective fact, rather than your subjective opinion! Where is this ranking order of artists, because I’d like to see it. And Mark Knopler has shifted a few albums in his time.

  52. beuges says:

    camillo said:

    "The first goal of a company is to make money and it seems to me that Microsoft is succesfully doing this. Probably their strategies are not so bad…"

    Paul Spendlove said:

    "As and when OSS ever gets the same level of market penetration as Microsoft, they will face precisely the same problems."

    Microsoft writes software to make money. MS writes new version of windows, people buy, MS makes money. If the software the customers already own (games, applications, whatever) does not work on the new version of windows, people just wont buy it. So it’s in Microsoft’s best interests to ensure that existing apps continue to work on new versions of windows, even if it means writing hacks or workarounds for it. Everything just keeps working, thanks to the tireless efforts of Raymond and his team.

    The attitude I consistently see from the OSS community (which is mostly slashdot, so granted its pretty skewed) is, "Hey, if something doesnt run on the newest {kernel|KDE|GNOME|…} you’ve got the source code, so you can fix the bugs yourself. Don’t keep us from changing our stuff just to support your stuff." Which is fine and dandy when you’re a programmer, and when you have the knowledge and time to actually debug someone else’s application. But what happens when grandma finds a program on a coverdisk for her *nix pc, but its compiled for KDE 3.x and she’s just got her new pc installed with the brand-new (as yet unwritten, i know) KDE 4? (bearing in mind that major version changes indicate API changes that break binary compatibility).

    OSS wont achieve the same level of market penetration as Microsoft does, until either every pc user becomes a programmer, or until they are willing to support backward compatibility in the same manner that microsoft does. Until then, "desktop linux" just won’t be a success.

    (this is not a troll :p)

  53. vince says:

    begues said:

    OSS wont achieve the same level of market penetration as Microsoft

    does, until either every pc user becomes a programmer, or until they

    are willing to support backward compatibility in the same manner that

    microsoft does. Until then, "desktop linux" just won’t be a success.

    Most OSS developers I know don’t want the market penetration of microsoft, especially if it means we have to stop doing the right thing and instead start doing horrible Microsoft-esque hacks. I know over Christmas I spent at least 20 hours on family/friend computers cleaning spyware, installing SP2, and re-installing. That’s 20 hours, unbilled… I’m basically providing support for free to a company I despise because all the "best and brightest" at MS are incompetent. I’m actually encouraged that MS wastes so much time on backwards compatibility because eventaully their code will be so slow and unmaintainable that no one will use it. MS is sacrificing long-term profitibility for short-term monetary gain. Maybe that is what capitalism is all about. Funny how people will say that making money is more important than user experience… then why wasn’t IE sold at the highest price the market would bear? Oh… for user experience. Well then I guess only Communists use IE ;)

  54. John Topley says:

    The Right Thing(tm) for a corporation *is* the most profitable thing. They’re not a charity. It’s called capitalism, you’ll get used to it.

    And how exactly is ensuring that existing software continues to run on new versions of the OS, marketing-led?

  55. Aaargh! says:

    "The Right Thing(tm) for a corporation *is* the most profitable thing."

    There’s two different viewpoints here:

    1) Writing code is a means for a corporation to generate profit.

    2) A corporation/profit is a way to finance the coding.

    I support the latter viewpoint.

    So what if the ugly code makes more money, it’s still ugly code.

    "you’re betraying a certain mind-set of the software as being more important than the processes that it is designed to support."

    It *IS* more important, that’s my point. And ultimately it leads to better software.

    "But I’d say that this is not an inappropriate attitude, because software is a means, not an end."

    To a programmer, it is not, and should never be.

    It’s the same as with music. A commercial artist like Britney Spears may be more profitable than e.g. Mark Knopfler, but the latter makes way better music.

  56. m says:

    vince,

    I’d be interested to know how you can conclude that the "best and brightest" at Microsoft are somehow "inompetent". What makes you think that?

  57. James Schend says:

    I’d be interesting in hearing how your friends and family members managed to hit the "yes" button when some spyware application wanted to install itself. It’s not like Windows is installing this stuff silently behind your back…

    (Although I’ve seen that happen to computers with file-sharing programs installed, like eDonkey or Kazaa. Those things are just huge targets for hackers, spammers, the works.)

    Besides, if your time’s worth so much, why not just install Linux or buy them MacOS computers which don’t have those problems? Nobody held a gun to their head and FORCED them to buy Windows computers, right?

  58. Vorn says:

    As a programmer:

    When updating an old piece of software, it is vital that software that depends on my software continues to get the same interface, or my software has obviously failed its unit tests. The only things I can do is make buggy things more reliable, and add features using different syntax. My software does not exist in a vacuum, and I know that. If I have to hack together a workaround, so be it. If I have to essentially freeze development on the old product and release the update as an entirely new product, so be it. My code is only there in the service of the ends meant of it, and if those ends did not exist, neither would my code.

    As a gamer:

    Making sure I can play old games means that new software must be able to run it. I can’t afford, in several senses, more than one or two computers to run games on. Why should I have to maintain a ten year old machine just so I can have Windows 3.11 so System Shock (which, by the way, doesn’t work on win2k) can run?

    Vorn

  59. Paul Spendlove says:

    Me: "…software is a means, not an end."

    You: "To a programmer, it is not, and should never be."

    Hmmmm.

    Well, I guess we might just have to agree to differ. But I’d like to expand where I’m coming from, since we may not be quite as far apart as you think.

    Most of the time, the problem isn’t whether there are some people there who can program. It’s whether there are some people there who can program and understand something about the problem domain that the program is supposed to help with.

    A concrete example: an aid worker uses Microsoft Access to run up an ad-hoc, scrappy database of post-tsunami aid distribution in the 50-mile-long patch of Indonesia coast that they’re covering. Now, that program is there, and it’s helping save lives *right now*.

    The writer is not a professional programmer. They’re using a software package I personally dislike (I genuinely do dislike Access). Their database design is screwy. It’s full of crappy validation code. Ugly, ugly, ugly. Yuk!

    But, of course, there *are* no highly-skilled programmers there on the ground. Instead, you’ve got some aid workers who can speak the local languages, knowing the local culture, being experienced in setting up emergency distribution networks and so on, and as a very small part of what they know, they can set up the necessary computing back-up to help run the first wave of release help.

    Is this program without worth? Personally, I reckon it’s worth more than most programs any of us will ever write in our lifetimes.

    My conclusion: In the messy, ugly, real world, software *can* be a means, rather than an end. You are, of course, at liberty to differ. But I hope I’ve put across my point a bit more clearly.

    PS: Mark Knopler? Hmmm, a wee bit beige in my eyes. I think a better illustration of how much mind-bendingly better non-commercial music can be is supplied by The Fall. But then, I’m biased.

  60. Aaargh! says:

    "My conclusion: In the messy, ugly, real world, software *can* be a means, rather than an end. You are, of course, at liberty to differ. But I hope I’ve put across my point a bit more clearly. "

    It’s all a question of scope.

    When you’re trying to save lifes, software can be a means to an end. But once you’re coding, the software is the end, not the means.

    Just like saving lives is a means to an end.

    If you’re a programmer, your scope is different than when you’re an aid worker. As a programmer, your first Duty is to the code. (I think we need a sort of Hippocratic oath for programmers). As an aid worker, you’re Duty is to safe lives.

    "PS: Mark Knopler? Hmmm, a wee bit beige in my eyes."

    Sure, but the man CAN handle a guitar.

    "I think a better illustration of how much mind-bendingly better non-commercial music can be is supplied by The Fall. But then, I’m biased."

    Never heard of them, I’ll check it out sometime.

  61. Cooney says:

    > My conclusion: In the messy, ugly, real world, software *can* be a means, rather than an end. You are, of course, at liberty to differ. But I hope I’ve put across my point a bit more clearly.

    Software is always a means. Period. Of course, this assumes that you follow things to their conclusion.

  62. Marcel says:

    I’m a developer of a much smaller operating system, but we too have the problem of having to support up to 20 years old legacy applications. We go a different way, however, I have developed at least a dozen patches for old binaries that clean up their code instead of littering the OS. It’s real work, but finding out what is causing the trouble is the main time killer and has to be done anyway.

    Especially in this pretty simple case I cannot see why this approach would be such a bad choice.

  63. Toma Bussarov says:

    Raymond, I have a suggestion. After all the things said here about error codes why don’t you continue in this way and write something about WIN32 error reporting mechanisms. And probably why Win9x sometimes set "last error" and sometimes not.

    All the best,

    Toma

  64. John Topley says:

    Marcel,

    How exactly do you clean up their code? Do you have access to the source?

  65. Cooney says:

    How exactly do you clean up their code? Do you have access to the source?

    No, he patches the binary.

  66. Marcel says:

    Right. I have almost never access to the sources, often even the original author doesn’t have them anymore (or he himself is MIA).

    Especially in a case like the one shown it is usually only a few bytes to patch, like exchanging the open call by code that always sets the handle to 2 (pedants may want to remove the close call, too). Somehow I do prefer that over changing the OS.

  67. John Topley says:

    I doubt Microsoft can patch other company’s binaries for legal reasons!

  68. vince says:

    m:<BR>

    vince,

    I’d be interested to know how you can conclude that the "best and

    brightest" at Microsoft are somehow "inompetent". What makes you think

    that?

    <BR><BR>

    Well, for one their blogs don’t have "preview" buttons so I can catch typos before really submitting the comment.

  69. CN says:

    Marcel: It was buggy of the software to use the error code as a file handle, sort-of. It probably just ignored the carry and so got the same return value.

    BUT, in my mind, it was buggy of Windows 95 to break the implicit contract of what would happen if the empty file was opened. I could imagine many other cases where the code would just handle error 2 and be very confused when a file name that contains no path gives error 3. This is not a fix for a single program, it’s a fix to keep a quite reasonable expectation on what will happen if this special case of a "file which does not exist" is opened. Voilà, file not found!

  70. CN says:

    One more thing: If MS had instead hard-wired "" to "stdout" from Windows 95 and on as a fix of this app, that would have been an ugly hack. That’s not what they did.

  71. Muck says:

    I have never tried it myself, but are modern PCs fast enough to run these mission-critical old DOS apps inside VMWare? That would put an end to all OS compatibility problems (which some people run into despite Microsoft’s efforts).

    Something else:

    IIRC, AMD64s cannot execute 16-bit binaries when run in 64-bit mode. So old legace Win3.11 code won’t run in WinXP 64-bit. Any insights why AMD apparently can get away with this, but Microsoft can’t?

  72. Marcel says:

    John: "I doubt Microsoft can patch other company’s binaries for legal reasons!"

    And on what reasons exactly? Disassembling and patching binaries is perfectly legal (at least in Germany) if otherwise the product didn’t work anymore for legal customers.

    CN: "I could imagine many other cases where the code would just handle error 2 and be very confused when a file name that contains no path gives error 3."

    Well, is an empty string a filename without a path or a path without a filename? ;-)

  73. kuwanger says:

    Much,

    AMD64 can’t execute native 32-bit code in 64-bit mode either, so it changes CPU mode. That’s, I assume, what WoW does for the most part; so, Win16 code should still work just fine by proper CPU mode switching. As for old DOS apps, there’s either the use of the DOS subsystem in Win NT or using an emulator like DosBox. Yes, VMWare/VirtualPC might also be an option (especially given that MS now owns VirtualPC), but I get the impression MS wants DOS to die. I’d assume they want Win16 to die as well.

    beuges,

    I’d say that the OSS mentality is more "if it’s horribly broken, fix it instead of supporting it". Thankfully, large parts of Linux and *BSD are coded separately. That means that fundamentally a lot of the broken interface code is noticed and fixed a lot earlier than it likely otherwise would be. It also means that fixing a layer is often sufficient to fixing all problems. So, while there have been all sorts of various fixes to the Linux kernel and redesigns to solve issues, generally only a few libraries and utilities that parse the output of exposed ascii files have to be altered.

    Paul Spendlove,

    Not to belabor the point too much, but imagine the same aid worker who stumbles across a backwards compatibility induced bug in said Access software that causes them to lose all data so far acquired. If bad design allows one misfeature pass through, what makes you believe the same bad design won’t let a variety of other misfeatures pass through that are never realized? The point of good design is fundamentally to make it difficult to impossible to have bugs, especially spurious ones. Yes, this does mean that some software will not work in the latest version of an OS. And maybe that aid worker would have to use an old version of Windows to continue using Access (no real offense to Access in all this, as it’s just the example in use). But because there aren’t major/any changes in this old version of Windows, any bugs that *do* exist will be more reproduceable.

    This is fundamentally why companies will continue to use old, knowingly buggy code; they know all the dangers. No amount of trying to maintain backwards compatibility will 100% succeed for all cases. And the ways in which something *does* fail will be spurious and hard to track. So include a compatibility mode and warn the older developers, then remove the compatibility mode next version/revision. And most of all, warn the users that your mid-version release really isn’t for anyone but the cutting edge, if they plan to use legacy software. Obviously, this is all against the mindset of trying to attract as many people as possible in to buy the software, but attracting lots of people in to use software while knowing that you’ve basically lied to some people about being able to reach the end through this new/"better" means must feel pretty bad. I’d guess that’s why Raymond takes it personally for all the applications that *do* break, no matter how much he tried.

    So, it’s not just about some programmer "idealism". It’s about knowing that there’s a lot you don’t know, can’t fix directly, and can’t help to prevent if you’re stuck in the old design. Designs change all the time. So long as users can continue to run the software on your old software they already own and you try your best to migrate over people before "cutting them off" on your new software so other software makers get off their collective butts (obviously assuming they exist; if not, you’re in a rather large design pickle, and then I’d be pressed to agree that nothing but either binary patches to the runtime executable or some other sort of hack would be fair..and of course warn users away from the software in a way they’ll realize you’re just trying to help them (hey, that’s what marketers/diplomats are for)) to fix the problem(s) (which admittedly are possibly/probably your company’s own fault), I just don’t see a good reason to be dragging along really bad design decisions across multiple versions of software.

  74. John Topley says:

    Muck: "I have never tried it myself, but are modern PCs fast enough to run these mission-critical old DOS apps inside VMWare? That would put an end to all OS compatibility problems (which some people run into despite Microsoft’s efforts)."

    Windows NT has always done that. ntvdm.exe is the NT Virtual DOS Machine and provides a virtual environment based on MS-DOS 5.0, I believe.

    Marcel: "Disassembling and patching binaries is perfectly legal (at least in Germany) if otherwise the product didn’t work anymore for legal customers."

    In the UK at least, I think that most software ships with a licence agreement that prevents disassembly and modification.

  75. Mike Swaim says:

    If you’re a programmer, your scope is

    > different than when you’re an aid worker. As

    > a programmer, your first Duty is to the

    > code.

    Nope. My first duty is to the people who are going to be using the code.

    Some friends of mine once interviewed a guy and asked him about a project that he was on. He completed it on time and under budget. It did everything they wanted, and passed acceptance testing. The users hated it, and threw it away.

    I’d call that project a failure.

    We try to write software that our users like. Our users respond by inviting us to their parties and giving us gift certificates. Sounds good, no?

  76. Aaargh! says:

    "Nope. My first duty is to the people who are going to be using the code."

    No, that’s the duty of the people managing the project.

    "Some friends of mine once interviewed a guy and asked him about a project that he was on. He completed it on time and under budget. It did everything they wanted, and passed acceptance testing. The users hated it, and threw it away."

    If it did everything they wanted, and passed acceptance tests, it’s probably due to not properly understanding the problem the software was supposed to solve, that’s not the duty of the programmer (using a narrow definition of programmer here). the programmer gets requirements and caffeine as input and outputs code.

  77. Marcel says:

    "In the UK at least, I think that most software ships with a licence agreement that prevents disassembly and modification."

    Well, here this part of the license wouldn’t be worth the paper it is written on. You always have that right if otherwise the product wouldn’t work.

  78. No, not that other side. Raymond Chen is a Microsoft programmer. I was amused by this post about MS-DOS error codes and a broken program. For the record, I’m with the commenters who voted for type checking and for fixing…

  79. ash says:

    It does work on Win2k.

    System Shock™ 2 FAQ

    Download this FAQ as a Word Document.

    1 General

    1.1 About this FAQ.

    1.2 What is System Shock 2?

    1.3 Who developed System Shock 2?

    1.4 Where do I go for technical support?

    1.5 Where do I get the patch?

    1.6 What does the patch do?

    1.7 Will the patch destroy my savegames?

    1.8 Will there ever be a System Shock 3?

    1.9 Where can I discuss System Shock 2?

    1.10 Will System Shock 2 ever be ported to other platforms?

    1.11 Is there an editor for System Shock 2?

    1.12 Why isn’t there an “official” System Shock 2 web site?

    2 Technical

    2.1 When I play the game I experience graphics glitches, it crashes, etc.

    2.2 How do I install System Shock 2 under Windows 2000?

    2.3 How do I play the game using a joystick?

    2.4 When I try to play the game, it freezes at startup.

    3 Gameplay (warning, includes spoilers!)

    3.1 I’ve killed the stars defending the Many boss but I still can’t destroy the Many.

    3.2 I’m stuck! How do I continue?

    3.3 I want to cheat!

    3.4 Are there are any Easter Eggs in the game?

    General

    About this FAQ.

    Hello, and welcome to the Irrational Games System Shock 2 FAQ. This is not in any way an "official" FAQ. It is a collection of data which has been compiled by us in response to questions that have been asked over the last couple of years. We hope to address as many issues as possible in here but we don’t provide any guarantees about the information contained within nor are we officially responsible for providing technical support for the game. That said, we will do our best to help you enjoy System Shock 2!

    What is System Shock 2?

    System Shock 2 is a science-fiction role-playing game. It is the sequel to the revolutionary System Shock, developed by Looking Glass Studios.

    Who developed System Shock 2?

    System Shock 2 was developed by Irrational Games in conjunction with Looking Glass Studios. It is published by Electronic Arts™.

    Where do I go for technical support?

    Electronic Arts is responsible for technical support for System Shock 2. You can contact their support department at http://www.ea.com/support .

    You can also find unofficial support at the Irrational web-site forums (www.irrationalgames.com/forum)

    Where do I get the patch?

    The System Shock 2 patch is available from the Irrational Games website ( http://www.irrationalgames.com/shock2/files/shkpatch.exe)

    What does the patch do?

    The patch contains numerous bug fixes including a fix to the “many stars” bug (see below). It also adds multi-player support.

    Will the patch destroy my savegames?

    No, the patch will not affect current savegames.

    Will there ever be a System Shock 3?

    There are no plans at the moment for System Shock 3 as far as we are aware. If you want a sequel, your best bet is to let EA know.

    Where can I discuss System Shock 2?

    At the Irrational Games web forum ( http://www.irrationalgames.com/forum)

    Will System Shock 2 ever be ported to other platforms?

    Yes, work is underway to port System Shock 2 to the Dreamcast.

    Is there an editor for System Shock 2?

    Yes, ShockEd has been released and you can download it and create your own System Shock 2 levels. However, it is not supported.

    Why isn’t there an “official” System Shock 2 web site?

    Electronic Arts does not maintain a System Shock 2 web site. Looking Glass Studios did have a System Shock 2 web site but they are no longer operating as a company.

    Technical

    When I play the game I experience graphics glitches, it crashes, etc.

    Make sure that you have the latest drivers for your video card. Check that your video card and other system elements meet the minimum specification for the game.

    Make sure that you are not running other applications at the same time, including virus checkers and other background processes.

    From the faq:

    http://www.irrationalgames.com/shock2/faq.cfm#2.2

    How do I install System Shock 2 under Windows 2000?

    Open a command prompt. Change the directory to your CD and type

    setup –lgntforce

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index