Showing tag results for Code

Jan 3, 2006
Post comments count0
Post likes count0

The world's slowest RET instruction

Raymond Chen

Occasionally, somebody will ask I'm debugging a hang, and I see that many threads are stuck at a RET instruction. When I try to trace one instruction from that thread, the trace breakpoint never fires. It's as if the RET instruction itself is wedged! I've found the world's slowest RET instruction. (A common variation on this theme is that the th...

Code
Jan 3, 2006
Post comments count0
Post likes count0

On the abuse of properties

Raymond Chen

One thing that I see occasionally is the abuse of property syntax. IDispatch and CLR objects (and C++ objects if you want to avail yourself of a Microsoft-specific extension) support "properties", which syntactically look like fields but internally are treated as a pair of methods ("get" and "put"). An important principle is that given an object ...

Code
Jan 3, 2006
Post comments count0
Post likes count0

There's more to calling a function than just getting the types to match

Raymond Chen

Here's a classic novice error. You want to call a function, say GetBinaryType. What should you write for those question marks? Well, the prototype says that the second parameter is an LPDWORD, so let's pass it one. Hm, but that crashes. Well, maybe we can pass it an LPDWORD this way: Hm, that still crashes. Oh wait, it's because of the...

Code
Dec 14, 2005
Post comments count0
Post likes count0

On the ambiguity of uniqueness

Raymond Chen

The MSDN documentation for says [T]he implementation of GetHashCode provided by the String class returns unique hash codes for unique string values. This is another case of ambiguous use of the word "unique". The intended meaning is "for each string value, the same hash code is returned". Even though "unique" means "one and only one", the...

Code
Dec 12, 2005
Post comments count0
Post likes count0

Your debugging code can be a security hole

Raymond Chen

When you're developing your debugging code, don't forget that just because it's only for debugging doesn't mean that you can forget about security. I remember one customer who asked (paraphrased) We have a service, and for testing purposes we want to be able to connect to this service and extract the private data that the service is managing, ...

Code
Nov 29, 2005
Post comments count0
Post likes count0

Taxes: Geopolitics

Raymond Chen

One frequently-overlooked software "tax" is geopolitics. We've alread seen that the time zone and regional settings dialogs created international unrest. It appears that Google Maps failed to recognize the extremely sensitive issue of naming the body of water that lies between Korea and Japan, as well as stirring up international tensions with ...

Code
Nov 28, 2005
Post comments count0
Post likes count1

Taxes: Hierarchical Storage Management

Raymond Chen

One of the taxes I alluded to some time ago when I broached the issues of software development "taxes" is Hierarchical Storage Management. The short description of Hierarchical Storage Management is that it is a way of archiving data transparently. When a file is due for archival, it is transferred to a slower (but less expensive) storage medium,...

Code
Nov 23, 2005
Post comments count0
Post likes count0

Semaphores don’t have owners

Raymond Chen

Unlike mutexes and critical sections, semaphores don't have owners. They merely have counts. The ReleaseSemaphore function increases the count associated with a semaphore by the specified amount. (This increase might release waiting threads.) But the thread releasing the semaphore need not be the same one that claimed it originally. This is dif...

Code
Nov 7, 2005
Post comments count0
Post likes count0

Take it easy on the automatic retries

Raymond Chen

When I saw a discussion of how to simulate retry via try/catch, using as inspiration a Ruby function that retried a network operation three times before finally giving up, I felt the need to caution against automatic retry. Your natural inclination when faced with a failure that has a good chance of being caused by a transient condition is to re...

Code
Nov 4, 2005
Post comments count0
Post likes count0

Why is there a special PostQuitMessage function?

Raymond Chen

Why is there a special PostQuitMessage function? Because it's not really a posted message. Commenter A. Skrobov asked, "What's the difference between and ?" They are not equivalent, though they may look that way at first glance. The differences are subtle but significant. Like the , , and messages, the message is not a "real" posted mess...

Code