Catching float- and struct-returning messages to nil

by Tim Wood on March 11, 2007

Wim came up with a neat trick a while back that we've used to find and fix several bugs in our software, and to file a bunch of Radars.  There are several messenger dispatch functions in the Objective-C runtime.  Of particular interest here are objc_msgSend_fpret and objc_msgSend_stret.  These are used by the compiler when calling a method that returns a float or struct, respectively.

Depending on your architecture, the result of such a message can be undefined when sent to nil.  Messaging nil is very useful most of the time, but you can introduce rarely manifesting bugs in this case.

Looking at the disassembly for these two functions in gdb, though, gives us an easy way to catch them.  Under 10.4.8/x86, we see the following:

(gdb) x/50i objc_msgSend_fpret

0x90a573c0 : mov 4(%esp),%eax

0x90a573c4 : test %eax,%eax

0x90a573c6 : je 0x90a57420

0x90a573c8 : mov 0(%eax),%eax

...

That is, load the first argument, check for zero, if so jump to 0x90a57420.

Likewise, in objc_msgSend_stret:

(gdb) x/50i objc_msgSend_stret

0x90a57340 : mov 8(%esp),%eax

0x90a57344 : test %eax,%eax

0x90a57346 : je 0x90a573a0

0x90a57348 : mov 0(%eax),%eax

...

In our ~/.gdbinit we can have:

# Nil-handling path for objc_msgSend_fpret.

b *0x90a57420

comm

p (char *)$ecx

end

# Nil-handling path for objc_msgSend_stret.

b *0x90a573a0

comm

p (char *)$ecx

end

(where the print command shows the selector).

 

OmniGraffle for Bureaucracy

by William Van Hecke on March 9, 2007

Good day.

It took me a while to realize this, but almost every time I need to put some kind of stuff on a page, and it makes a difference where on the page that stuff is, OmniGraffle ends up being the best tool for the job.

Let me 'splain: OmniGraffle might not be the first thing that comes to mind when you need to fill out some official forms for the U.S. Government. Or, say, some character sheets for your weekend Dungeons & Dragons session. But it should be. Check this out:

  • Grab an electronic version of the form you need to fill out. Scan it if you have to, but most official forms are available as PDFs these days. Some of them even claim to be fillable, but I've never gotten them to work properly in Preview or Acrobat.
  • Copy each page from the document (in Preview) and paste it onto a fresh OmniGraffle canvas.
  • For each canvas, lock the layer that has the form on it, and create a new layer for your information.
  • Make text objects all over the canvas to fill in each blank. Once you have a text object you like, you can Option-drag it or paste it all over and just replace the text.

omnigraffle-form-fill-out.png

Why this is so much handier than filling out forms by hand:

  • You can use the alignment inspector and smart guides to make sure everything is lined up just right and perfectly legible.
  • If some of the boxes are really tiny, you can play around with the font to get everything to fit in there just right.
  • Filling out the same info over and over is easy: just copy and paste the existing text objects with the info you need.
  • Once you've saved the file, you automatically have a backup copy for reference or revision.
  • You can make an OmniGraffle template that has the right paper size, two layers per canvas, and a nice grid for keeping things orderly.

When I was going through the process to get someone a visa to live in the USA, this technique saved me heaps of time and stress. And now I have backups of every form (there are lots of forms involved).

Have you found any weird or unexpected uses for Omni apps? Maybe next time I'll tell you about how I'm using OmniGraffle as a level editor for a video game I'm working on…

 

OmniPlan 1.1 beta 4

by William Van Hecke on March 8, 2007

This beta release contains plenty of stability, import/export, printing, and AppleScript support improvements. We have completed the AppleScript changes that were planned for 1.1, so if you run into any problems there, be sure to let us know.

Please keep in mind that this release is still under development. Your feedback will help us improve the software, and we apologize if it crashes, corrupts your files, steps on the piano keys at night, or otherwise misbehaves. A more stable release is also available.

As always, please let us know if you have any questions or comments. You can contact us directly via our support page or by using the Send Feedback command in OmniPlan's Help menu.

Download and enjoy.

 

Omni goes skating, skating rink wins.

by Rowan on March 5, 2007

To celebrate the launch of OmniPlan, the Omnis went to the Lynwood Skate and Bowl, where we had way too much fun.  What we discovered is that Ken has an alternate life as a professional roller skater (or something), and proceeded to skate circles around the rest of us (usually backwards, on one skate).  He then took us to the bowling alley, where he showed me how to throw many strikes in a row.  I did not fare as well, but at least I beat my old record of 27.

There were unconfirmed reports of some morning-after sickness which may or may not have been related to the food, though apparently people not even present had some problems, which tells me that the food served was of a truly spectacular and long-reaching variety.

Liz decided that she didn't need her wrist guards that she uses for rollerblading, she was wrong:

liz broken