Archive for the 'Techie' Category

Results of Stray Event Scanner evaluation at a customer site

Tuesday, August 19th, 2008

As I mentioned, about a week ago I visited a customer site to find out if our Stray Event Scanner tool actually did the trick, on their codebase. That customer has kindly said I can post some results here.

Results were mixed!

Proportion of this customer’s codebase scanned 5% (estimate).
False positives reported by the tool 47
Of which are things I might be able to fix 37
are intrinsic limitations 8
are already fixed in a later development version of the tool 2
Interestingly, 35 of these false-positives were in one smallish area of code. It seems that some Symbian OS code conforms to the norms expected by the tool, whilst some code really gets is unnecessarily overexcited. All the rest of the code we scanned only produced 12 false-positives.
Real bugs found by the tool 14
Of which tool was precise about the problem 6
tool was wrong, or vague, about the specific problem but did identify the right bit of faulty code 8
Actual bugs filed in this customer’s defect-tracking system 10 (because the other four were duplicates)

Conclusions. Good things first…

  • As expected, the tool found plenty of bugs. Nearly all of these bugs were real problems which could cause E32USER-CBase 46 panics under some circumstances, which are awful to diagnose.
  • In fact one of them was a duplicate of an existing E32USER-CBase 46 bug, which they’d been searching for for some time, but had been unable to find. Result!
  • The tool broadly worked as planned. There were no hopeless incompatibilities with their source code.
  • With the exception of that one component, there were far fewer false-positives than I realised.

Bad things…

  • There were lots of false-positives in that one component. Many of these will be impossible to remove using the current analysis method.
  • In some cases the tool was not very accurate about specifying exactly what was wrong with the code. It would identify the right area of code, but a lot of examination and thought was required to identify whether there really was a problem there. Again, there’s not much that can be done about this: stray event problems are intrinsically complicated and somebody technically experienced will be required to analyse the results.

Next steps…

  • See how many of those false-positives I can remove easily
  • Fix a few other minor bugs that cropped up
  • Decide whether the tool is ready to leave the beta stage!

DTrace is very good

Monday, August 18th, 2008

One of the things which would make Macrobug’s life much easier is if Symbian OS had DTrace or an equivalent. DTrace is a dynamic tracing framework which allows arbitrary APIs and function calls to be instrumented at run-time without any changes to any code. That way, the Macrobug tools would be able to hook in and monitor what’s happening inside the device without any changes to the kernel or application binaries.

Such days are probably some way away, but I can look forward to it!

Meanwhile, just as an example of how great DTrace is on a real system, I’ve just used it to diagnose a problem with my Mac. Macs include a backup mechanism known as Time Machine. This does incremental backups, in my case onto a RAIDed NAS server sitting elsewhere in my house (which in turn has parts of it rsync’ed to an off-site backup regularly).

Time Machine backs up automatically every hour in the background, and keeps as many incremental backups as it can fit onto the backup disk. There’s therefore an incentive for the backups to be smallish, as then your history will go back further. I found that most Macs seem to back up about 1-3 MB every hour, whereas mine always backed up 105-110MB. What was this mysterious file which was changing every hour that seemed to be 105MB big?

To diagnose this, I used Apple’s whizzy DTrace front-end, known as Instruments, to attach to the “backupd” process which does the time machine backups. I used some preset DTrace probes which can instrument the APIs used to read and write files, thus giving me lists of all the reads and writes, including their sizes, filenames, and even call stacks. And there’s even a nice UI to look at the results:

Instruments UI

The mysterious 105MB file turned out to be the article database for my RSS reader. It appears that they store all the articles in one file (messages.db) instead of many small ones. So, each time it refreshes (more than once per hour) the file changes, and Time Machine chooses to back it up.

So, the solution is simple - check whether there’s a fixed version of Vienna, or move to a new RSS reader, or tell Time Machine to ignore this file.

As for Symbian, perhaps there will be something like DTrace one day! I can’t wait!

PIPS on Motorola Z8

Friday, August 15th, 2008

PIPS is Symbian’s newish POSIX API layer. On the whole it’s pretty good; the APIs work well, although there is not much support for “related issues” such as building using GNU autoconf, link-by-name, and interfacing with other Symbian code.

However, PIPS 1.3 doesn’t work on Motorola phones. This means a customer of mine can’t release their software for Motorola devices, and the same will apply to many others I’m sure.

So, for the record, here’s Motorola’s explanation:

“We found that PIPS 1.3 is not supported with Motorola Z8 devices as no manufacturing capabilities are supported with Z8 in order to install PIPS 1.3 Software applications.We no longer intend to support with Z8.”

“However we are evaluating to support with our future UIQ devices for PIPS 1.3 Software application installation. Hopefully we will support.”

That’s nice, then!

(In all fairness, contrary to what Motorola Developer Support say above, I’ve been told from other sources that this is a temporary situation, and PIPS should work again on all Motorola phones - including the Z8 - in due course.)

Carbide.c++ and Qt

Wednesday, August 13th, 2008

The Carbide.c++ team has released the first Milestone release of Carbide.c++ 2.0.

There are two interesting things about this release.

The first is that an indexer bug has been fixed to work with templated types. Symbian OS descriptors are usually templated types, and so this is a big deal. It means a lot of features now work with Symbian APIs which previously didn’t - such as the call hierarchy, F3 to open definition, etc.

Just like in previous Carbide.c++ versions, when Carbide can’t understand your code, the code is shown in grey. The difference is that in previous Carbide builds it was probably a Carbide bug, whereas now it’s 99% likely to be a bug in your code. Several times now I’ve thought to myself, “oh, that code looks fine, Carbide must be imagining it” and sure enough, the indexer is right, I’ve messed something up.

For those reasons alone I wholeheartedly recommend joining the Carbide.c++ 2.0 beta and using the new version.

The second thing is the presence of a new perspective in Carbide.c++ - a Qt perspective. A few months ago, you might have noticed Nokia bought Trolltech, the makers of Qt. At the time there was speculation about what Nokia would do. Would they port Qt on top of S60? Would they replace S60? Would they start to make Linux/QT phones?

Well, the first answers are beginning to appear in this version of Carbide.c++. For example, the Qt perspective has editors for Qt actions, properties, objects, slots and widgets. That seems a lot to me, and although these views appear to belong to a com.trolltech.qtcppdesigner package and therefore aren’t produced by the Carbide.c++ team, it looks like a lot of the effort in Carbide.c++ 2.0 has gone into Qt work as well as Symbian work. I may be wrong!

Also, the Qt perspective doesn’t show the Symbian Project Navigator view. There’s nothing in that view which is specific to Symbian UIs - it’s all about the Symbian build system. That suggests to me that whatever Qt stuff is going to be happening in Carbide.c++ 2.0, it will not involve the Symbian build system, which in turn means it’s based on Linux (or something) rather than Symbian.

Again, I may be wrong, but that’s my prediction. It looks to me like Carbide.c++ is going to turn into a dual-purpose tool: Qt/Linux as well as S60/Symbian, rather than Qt-on-Symbian. It will be interesting to find out if I’m completely off the mark.

(Incidentally, this leads onto another vague interest of mine - getting the cross-platform make system cmake to generate Symbian OS MMP and bld.inf files. I vaguely plan to investigate that one day, but haven’t yet. I believe that KDE uses cmake, which suggests it’s popular in the Qt world. If there is any crossover, perhaps that’s been done somewhere already.)

New release of stray event scanner tool: 1.0.18

Sunday, August 10th, 2008

This clears up a few bugs, displays the conditions more nicely, and makes things quicker. Use Carbide’s built-in software update to fetch the new version.

Tough bugs

Tuesday, July 15th, 2008

I’m still working on fixing the remaining known problems in Macrobug’s Stray Event Scanner.

I don’t intend to try to make it perfect - because, when understanding code, there’s always an exponential effort required to understand the rarest features. For example, the tool will never support the C goto keyword where it skips backwards up a function. (The tool already supports forward gotos!)

But, I do want to enhance support for a few more things. For example, if code Leaves, it currently considers what happens when the code either leaves or it doesn’t. That’s usually correct, apart from when functions are used which are always guaranteed to leave (for example, User::Leave). Then the tool should only consider the code path which occurs if the function does leave, and any errors after that should not be reported (until of course the leave is trapped). Unfortunately, this is tricker than it sounds given the tool’s current architecture.

In short, I think I’ve fixed most of the easy bugs and I’m now facing the exponential curve of tricky obscure things to fix! Let’s see how far up that curve I get before giving up and rolling back down again. I want to make the tool output as good as possible, but it’s already much better than having no means to detect these problems.

Stray Event Scanner Launched

Wednesday, July 9th, 2008

Macrobug is proud to present its first product for actual sale: the Stray Event Scanner. This is a source code analysis tool which does one thing, and does it well: it finds the causes of the dreaded Stray Event panic. Why are they dreaded? Well, by the time the crash has happened, the reason is lost in the mists of time, so there’s no way to diagnose them except to read reams of source code and spot the mistake.

The Macrobug Stray Event Scanner does that for you. It uses GCCXML to build your source code, and then analyses the results to ensure that each any every time you make a request, you are somehow getting ready for the reply to be received.

Problem marker from Stray Event Scanner

And yes, the problem messages are so descriptive they don’t even fit on this website.

Download the demonstration version now, or buy the real one!

Using HP Printer Driver on ReadyNAS from MacOS X: part 3/3

Saturday, May 17th, 2008

Well, I still can’t find any software which will allow me to use the standard HP drivers with the DeskJet. (See parts one and two for the explanation). But, there’s another open-source alternative to Gutenprint’s HP driver: HPIJS - which works great! It’s still not brilliantly fast, but it supports multiple paper types, and most importantly, duplex printing - so I’m happy!

Using HP Printer Driver on ReadyNAS from MacOS X: part 2/3

Saturday, May 17th, 2008

Part two of my saga of trying to get my HP DeskJet 940C to print nicely from MacOS X despite it being attached to my ReadyNAS. Bonjour Browser, we can see that the Airport Express is advertising:

  • _pdl-datastream._tcp., a “Printer PDL Data Stream”, and
  • _riousbprint._tcp., a “Remote I/O USB Printer”

So, not IPP at all.

What we need to do, then, is get the ReadyNAS to advertise itself as a remotely controllable USB device, instead of (as well as?) an IPP printer. But do we need _pdl-datastream, or _riousbprint, or both?

Specifically, this is how it appears over Bonjour from the AirportExpress:

_pdl-datastream._tcp.
192.168.0.6:9100
txtvers=1
qtotal=1
note=Living Room
product=(HEWLETT-PACKARD DESKJET 940C)
pdl=application/vnd.hp-PCL
priority=5
usb_MFG=HEWLETT-PACKARD
usb_MDL=DESKJET 940C
usb_C
ty=HEWLETT_PACKARD DESKJET 940C

_riousbprint._tcp.
192.168.0.6:10000
txtvers=1
qtotal=1
note=Living Room
product=(HEWLETT-PACKARD DESKJET 940C)
rp=HEWLETT-PACKARD DESKJET 940C HU1B96N1ZZBH
pdl=application/MLC,application/PCL,application/PML
priority=1
usb_MFG=HE

Well, looking at a Wireshark dump of the transaction, we’re talking to port 10000: the remote USB service. Unsurprising, really. To be honest it’s more surprising that the Airport Express provides the other service (which makes it look like an HP JetDirect to PCs, I suppose).

So, we “just” need a package we can install on the ReadyNAS using apt, which exposes the USB device using this protocol. Sadly I can’t find such a Linux project, and nor can I find documentation on the protocol so I can’t have a go at writing one myself. Which is probably a good thing, as I have more important things I should be doing!

Summary: it’s not impossible after all, somebody just needs to write some software!

Using HP Printer Driver on ReadyNAS from MacOS X: part 1/3

Saturday, May 17th, 2008

I’ve just bought a ReadyNAS NV+, a NAS box onto which I will do all my backups. It’s great: amongst other things you can log into it using SSH, and use apt-get to install packages, which opens up lots of opportunities such as running my Subversion server on it.

I also wanted to share my old-ish HP DeskJet 940C inkjet from it. Upon connecting it to the USB port on the ReadyNAS, it appeared in Bonjour and I was able to print with it from my Mac - but only using the Gutenprint driver, rather than HP’s own driver. This was not a problem when it was attached to my old Power Mac G4 sitting in the corner… but I’d hoped to retire that. Unfortunately, the Gutenprint driver is slower, doesn’t support different types of paper, nor duplex. It’s good, but it’s not good enough.

I’ve spent a couple of hours researching the problem and have concluded that it’s impossible to solve. Here’s my reasoning. If anyone can find a way round these problems that would be terrific!

How printing works on MacOS X

MacOS X uses a printing system called CUPS. This knows about the printers installed, and manages queues of documents for them. You can control CUPS using the Printers preference page, or by logging into your own Mac on port 631 using a web browser.

The settings for each CUPS printer consist of three things behind the scenes:

  1. An entry in /etc/cups/printers.conf which says very little except…
  2. A URL to which the printer data should be delivered
  3. A PPD (Postscript Printer Description file) in /etc/cups/ppd

The key part is the PPD. This specifies all the capabilities of the printer. It also specifies how to process the data for the printer… and this is done in terms of the “cupsFilter” element. It describes whether the printer can accept a given MIME type directly. If not, it can also specify that the printer can accept that MIME type if the data is fed through a certain programme. CUPS will chain together these “filters” to convert from the original data type to one which the printer can actually accept. For example,a PICT image might be converted to PDF, then to a general bitmap, then to a bitmap format suitable for the printer.

HP Sources

Here are the cupsFilter details for my HP DeskJet 940c…

Driver Connection Filters
Gutenprint Over IPP to ReadyNAS *cupsFilter: “application/vnd.cups-raster 100 rastertogutenprint.5.1″
HP Locally over USB *cupsFilter: “application/pdf 0 /System/Library/Printers/Libraries/PrintJobMgr/Contents/MacOS/PrintJobMgr”
IPP to my Mac G4 *cupsFilter: “application/pdf 0 -”

*cupsFilter: “application/pictwps 0 -”

*cupsFilter: “image/* 0 -”

So, for Gutenprint, a general CUPS raster (which CUPS intrinsically knows how to accept) is converted by the program “rastertogutenprint5.1″ to the data format specific for the printer. CUPS then sends that across the network to the ReadyNas, and all is well.

If you’re using the standard HP driver locally, it uses a command “PrintJobMgr” to send the data to the actual printer. This takes a PDF and does something to convert it to HP’s format.

If you’re using an HP printer connected to a remote Mac, things are very different - it just sends the PDF, PICT or any image format directly to the other Mac - which will then send it through CUPS again, eventually resulting in a PDF form of the data making its way into PrintJobMgr on that distant Mac.

So what’s this mysterious PrintJobMgr? Unfortunately that’s where it all gets a bit depressing. Back in the early days of MacOS X (before 10.2) it didn’t use CUPS - instead it used a “Printer Manager” framework, codenamed Tioga. It appears that PrintJobMgr is a call from CUPS into that older system. That means, the process of converting from PDF (etc.) to the HP-specific data stream is not embedded in a nice executable which we can call from a cupsFilter before sending the data to the ReadyNAS. There’s simply no way to get the data out of the HP driver so that we can send it across the network.

So the HP driver is out - we’d have to run it on the ReadyNAS which means we’d have to run OS X on the ReadyNAS.

What about using “gutenprint.5.1″ to convert to the HP data format, but using the rest of the HP PPD file to configure the available options? I haven’t tried this, but I think it’s a non-starter. According to the Gutenprint user’s manual, the rest of the PPD is very specific to the Gutenprint driver. It specifically says that rastertogutenprint5.1 will fail if you use a PPD other than the one which comes with Gutenprint.

Unfortunately, it seems that to use a DeskJet attached to the ReadyNAS we have no choice but to use Gutenprint.

Update: it’s just occurred to me that the Airport Express is supposed to support printer sharing. I can’t believe it’s running the HP printer driver internally. So perhaps there’s a way… more on that later!