December, 2009

  • The Old New Thing

    I'm sorry, Brian/Bryan Gregory, that confirming the spelling of your name is too much for you to handle

    • 27 Comments

    At 10am on November 30, I received a telephone call at work with "Anonymous" as the caller ID. Strange. But maybe it's the same person who called my office phone from New York at 1am on the day after Thanksgiving and didn't leave a message, and they're just following up on the first business day after the holiday weekend.

    "Hello?"

    Hello, this is Brian Gregory from Fred Asher Associates and I'm calling blah blah blah blah blah are you interested in this opportunity or know someone who is?

    I may have gotten the names wrong since he spoke so quickly.

    "I'm sorry, that was a bit fast. Your name is Brian Gregory?"

    That's right.

    "Is that with an I or a Y?"

    Why do you need to know my name?

    What a strange question. This is information he volunteered at the start of the call, and besides, it's only polite to identify yourself when you call someone.

    "I just need to log this call."

    Are you interested?

    "We can get to that once I get some basic information. Is Brian spelled with an I or a Y?"

    Why does it matter?

    "I need to log this call so I can record my time, that's all."

    — *click*

    I guess it wasn't important. I mean, if it was important, you probably want the person to get your name right.

  • The Old New Thing

    What is the story behind multimon.h?

    • 24 Comments

    Commenter asdf wonders what the deal is with that multimon.h header file.

    Let's set some context. That header file was written back in the time when Windows 98 was still under development. Windows 98 was the first version of Windows to support multiple monitors. At the time, most application authors had Windows 95 as their target platform. And even after Windows 98 shipped, the expectation was that programmers would target both Windows 95 and Windows 98 for at least a little while longer.

    The problem then is convincing programmers to write their code in a manner that works well in the face of multiple monitors. If you say, "Well, you need to call these functions, but only if running on a version of Windows which supports multiple monitors. If running on an older version of Windows, then you'll need to keep doing things the old way because the functions you want to call don't exist there."

    Remember, if you want people to do something that doesn't directly benefit them, you need to make it easy or they won't bother. Therefore, the multimon.h header file was created which did the dirty work of checking whether it was running on a version of Windows which supported multiple monitors. If so, then it called those functions, and if not, then it emulated them. Applications could then use the multimon.h header file and write code on the assumption that the operating system supported multiple monitors: If it didn't, then the stub functions in multimon.h would kick in and implement "fake multimonitor support". For example, if you called GetSystemMetrics(SM_CMONITORS), the stub function would simply return 1. If you asked for GetSystemMetrics(SM_CXVIRTUALSCREEN), the stub function just gave you the width of the (one) monitor.

    Of course, those old versions of Windows which don't support multiple monitors are long obsolete, and there is no longer any need for the multimon.h header file. It long ago accomplished its intended goal. Give it a nice pat on the back.

    But the header file still lingers in the Platform SDK. If you have a program written back in the days when you couldn't count on multiple monitor support, then removing that header file would result in a build break in your program. That wouldn't be fun.

  • The Old New Thing

    Why do some comments have a star?

    • 28 Comments

    Every so often, someone posts a really funny comment, and I feel stupid just posting the remark "Haha, that was funny" or even worse "LOL". So I'm going to try giving them a star instead.

    Chris Blackwell wins the first star.

    Hopefully people won't post comments just fishing for a star. (I realize that this is a vain hope and that I will probably have to cancel the star program within the week.)

  • The Old New Thing

    When there is a long line of people waiting for a shared resource, you want to investigate the person who is hogging the resource, not the people waiting in line for it

    • 16 Comments

    If you see a long line of people waiting for a phone booth (note: this analogy assumes you remember how phone booths work), and you want to understand the reason for the long line, do you

    • Go to a person waiting in line and begin your investigation there?
    • Go to the phone booth (and the person inside) and begin your investigation there?

    If there is a long line of people waiting for a single resource, a resource that there is not normally a long line for, you would probably look at the person who is using the resource to see if, for example, they are a chatterbox who will be on the phone for an hour, or if the phone is being repaired or is otherwise not working properly.

    Similarly, if you find that in your 20-thread program, 17 of them are waiting for a single critical section, then you probably want to investigate the thread that owns the critical section to see whether (and why) it isn't releasing it.

    When testing a program, I encountered a hang that occurred after doing X. There are a few threads stuck in LoadLibrary, and about 40 threads stuck here:

    ntdll!KiFastSystemCallRet
    ntdll!ZwWaitForSingleObject+0xc
    ntdll!RtlpWaitForCriticalSection+0x132
    ntdll!RtlEnterCriticalSection+0x46
    ntdll!_LdrpInitialize+0xf0
    ntdll!KiUserApcDispatcher+0x7
    

    Here is one of the threads that is stuck in LoadLibrary [stack trace deleted]. You seem to be one of the people who work on the component that is trying to load the library. Can you investigate why the program is stuck?

    This person picked one of the people waiting in line and decided that they were the ones responsible for the problem. But if course, that person waiting in line is just another victim of the person at the head of the line who is hogging the critical section. In this case, the critical section is the infamous loader lock. That it's the loader lock is obvious from the symptoms: What critical section does every thread require when it starts up? What critical section does LoadLibrary require?

    You can use the !critsec debugger command to identify the current owner of the loader lock, and then start studying that thread to see what the hold-up is.

    Note that I'm not saying that the thread that owns the resource is necessarily the culprit. The problem could be in the resource itself, or it could be in the pattern of usage associated with that resource. But starting your investigation with the owner of the resource is a good bet, because most of the time, the reason for the long wait queue is that the current owner of the resource isn't releasing it.

  • The Old New Thing

    Why do Swedes count "1, X, 2"?

    • 25 Comments

    Occasionally, when an article in Swedish needs to count off three items, they are not labelled "1, 2, 3" but rather "1, X, 2". Why is that?

    I asked Jesper Holmberg, and he was kind enough to explain. (The entire exchange naturally was conducted in Swedish. Here's my translation.)

    As with most of the good things in life, it has to do with football [soccer].

    In Sweden, it is not only legal to bet on horse races, football, and other stuff, but the Swedish government even has its own betting agency. "One, cross, or two" comes from the betting ticket, the slip of paper you fill in when you bet on football or hockey. The ticket consists of thirteen matches, and for each match you choose whether you think the home team will win (1), whether the visiting team will win (2), or whether you think it will be a draw (X). You can see an example of the ticket by going to http://www.svenskaspel.se/ and clicking on "Stryktipset" in the upper left corner.

    If you want, you can, in one or more matches, choose two options, if you, for example, think that the home team is going to either win or draw. This is called "half-covering" (halvgardera). You can even mark all three, which is then "full-covering" (helgardera). The odds of winning goes up, but also the cost of playing. (My grandfather and I would bet on football on the weekends when I was little; it took us hours to fill in the ticket, analyze statistics, discuss odds, the payouts... I don't think we ever won a dime.)

    So this is how I interpret why that blogger you linked to chose 1X2 instead of 123: The point he's trying to make is that the answer is somewhat random, possibly even unknown. With 1X2, there's more of a sense of betting on circumstances one doesn't control, while 123 is more of a quiz where it's up to you to win or lose. I dunno, maybe I'm overanalyzing. Maybe he's just got a gambling addiction!

    I thanked Jesper for his explanation, noting that I had been wondering about this for many years. "Now it makes sense. No, I'm lying. It doesn't make sense, but at least it's less confusing. It was more like a joke targetting people who bet on football or hockey! On the other hand, it's probably impossible to find a Swede who doesn't bet on football or hockey..."

  • The Old New Thing

    What is the effect of setting the /3GB switch on my 64-bit Windows machine?

    • 41 Comments

    Nothing.

  • The Old New Thing

    Fake trend watch: Bridesmaid pre-nuptial agreements

    • 31 Comments

    My wanderings through the online world of bridesmaid craziness began with the article Brides taking their bridesmaids for Botox treatments or maybe a boob job. I blame the wedding-industrial complex, which constantly pushes weddings as the bride's "perfect day", "the best day of your life", a "fairy tale come true" where you can be "a princess for a day." (Folk tales which end in big lavish weddings are told from the female point of view; there aren't many folk tales about the young boy who grows up to marry a beautiful princess.)

    And I love Elizabeth A.'s comment called out in the sidebar to the New York Times article.

    Back to that article: Is the Botox girl's night out a real trend or a fake trend? In Pre-nups for bridesmaids. Gain weight and you're out, the author claims that "one in five women actually ask their bridesmaids to sign a pre-nup." On that, I call fake trend.

    First of all, I could find only one actual documented case of a bride who made her bridesmaids sign contracts agreeing not to gain weight before the wedding. And it was a prank.

    Okay, so if it happened only once, where did this "one in five" come from? I followed the citation to the source article in The Daily Mail, which merely says that one in five would ask their bridesmaids to sign such an agreement, not that one in five actually did it.

    But wait, there's more. I followed the citation from that Daily Mail article to the the original survey from You & Your Wedding magazine, and found that it was even weaker than The Daily Mail described it: The actual result was that one in five would consider a bridesmaid contract in general. So we're double-counterfactual now. And the survey was not scientific; it was just an online survey.

    Okay, so let's tally up the numbers. The claim that one in five brides ask their bridesmaids to sign a pre-nuptial agreement which includes a clause regarding weight would be true if...

    • The online survey results were representative of brides as a whole (and the people who answered the survey were answering seriously), and
    • Everyone who would consider having a bridesmaid pre-nup actually did consider it, and
    • Everyone who considered it followed through and did it, and
    • Every one of those pre-nups contained a clause regarding weight.

    I call fake trend.

    Bonus link: Extreme wedding planning. Warning: Contains bad dancing.

  • The Old New Thing

    A shell extension is a guest in someone else's house; don't go changing the carpet

    • 21 Comments

    A customer was running into this problem with a shell extension:

    I am writing a shell namespace extension. I need to get data from a COM server, which requires impersonation via CoInitializeSecurity with RPC_C_IMP_LEVEL_IMPERSONATE. As I am just writing an extension into explorer.exe, I am not able to call CoInitialize, CoInitializeSecurity anymore from my extension. Is there a way I can start explorer.exe by setting RPC_C_IMP_LEVEL_IMPERSONATE in its COM initialization? I was browsing through web, and explorer.exe seems to take some settings from registry, but couldn't find anything related to this one.

    First of all, who says that the host process is explorer.exe? If I open Notepad, then do a File.Open, and then navigate to your shell extension, boom, your shell extension is now loaded into Notepad, and I doubt you told Notepad that you wanted it to initialize COM in a special way, just for you. Same goes for Quicken, Lotus Notes, all those other programs that use the shell. Even if you solved the problem for Explorer, that doesn't solve your problem in general.

    Second, what if two shell extensions did this? Your shell extension requires RPC_C_IMP_LEVEL_IMPERSONATE, but another one requires RPC_C_IMP_LEVEL_DELEGATE. Who wins? Or are those shell extensions mutually incompatible? And what about the effect your decision has on the other shell extensions hosted by Explorer? Now they are running with RPC_C_IMP_LEVEL_IMPERSONATE even though they didn't ask for it. Will that introduce a security vulnerability? Will those other shell extensions stop working or even crash?

    A shell extension is a guest in the host process's house. You don't go and change the color of the carpet when you are invited over for dinner.

    This question is yet another example of using a global setting to solve a local problem. To solve your local problem (I need this specific COM interface to run with impersonation), use a local solution.

  • The Old New Thing

    Intelius cancels its cell phone directory, saving me the trouble of having to opt out of it every three months

    • 16 Comments

    A few years ago, I wrote about a new cell phone directory that charges $15 to give you incorrect information, and from which you have to renew your opt-out every three months. Well, apparently, less than a year later, due to "complaints from consumers and Verizon Wireless," Intelius decided to discontinue the service.

    Intelius is back in the news, because they have filed a preliminary prospectus with the SEC for an initial public offering. (According to TechCrunch, this is their second attempt at an IPO.) "It's important to know the history. Many investors looking at his history would be very careful." The person being referred to by that analyst is your friend and mine, Naveen Jain, current CEO of Intelius and more notably former CEO of InfoSpace.

    My guess is that Naveen did this for the attention, because it has been too long since the last time he got to tell a reporter how awesome he is.

    (By the way, his Wikipedia article at publication time demonstrates a bit of Naveen-like grandstanding. The article claims that he joined Microsoft in 1989 as a senior executive. I worked in an office down the hall from him in the early 1990's. He was no senior executive. He was just another middle manager, notable for being significantly more annoying and loud-mouthed than your average middle manager. And the quotation "My job was to define what a product should do from a consumer point of view and what it is that Microsoft wanted the program to be" is just the job description of a Program Manager at Microsoft. Nothing special.)

  • The Old New Thing

    Microspeak: Cookie licking

    • 23 Comments

    Cookie licking is the act of claiming something as something only you can do, but without actually doing it. (Note: This is considered a bad thing.)

    I have not seen this particular phrase in action, but I'm under the impression it comes from the Microsoft Research part of campus.

    The metaphor employed here is a plate of cookies. You've pigged out on cookies and you're full, but you take a cookie, lick it, and then put it back on the plate. Since nobody wants to eat a cookie that somebody else has licked, this effectively allows you to claim the cookie without actually having to eat it. (You never even had to put it on your plate.)

    Suppose there is a list of items to be done, say, tasks or projects or topics for investigation. Somebody signals interest in a particular project, thereby making it unavailable for others to work on. If the person never actually starts working on the project, then that person is accused of engaging in cookie licking.

    Cookie licking takes place at higher levels, too. For example, one team might come up with an idea for a feature, but they will be told by another team, "That's something we've been thinking about for a while," as a way for the second team to take control of the feature away from the first team. In extreme cases, that other team may not actually have been thinking about the feature at all, but by merely saying that they have, they have asserted their claim to it.

    Explaining it again: In the comments, it looks like someone else doesn't quite understand what cookie licking is, since he/she brings up a number of examples which aren't cookie licking. Since other people might be similarly mistaken, let me try again.

    Cookie licking is a tactic to prevent somebody from doing something by saying that only you can do it. It's a way of taking things away from others.

    "Announcing an OS without actually delivering quickly" is not cookie licking. Announcing the OS doesn't prevent other companies from developing their own. Announcing a product and delivering it late is embarrassing, but it's not cookie licking.

    Similarly, announcing a successor product, which stifles interest in the current product is not cookie licking. The current product is already out there; nobody took it away. The marketing team may have made a serious error in judgement, but no cookie licking took place.

    In both cases, the examples fail to capture the concept of preventing people from doing something by saying that only you can do it. It is a political tactic internal to an organization, not something done in public.

Page 4 of 4 (40 items) 1234