I don't normally blog about work. Mostly because it's not exactly a thrilling subject for most people. And I'm not really one for gossiping and complaining about coworkers, even if there was any juicy gossip going around or anything legit to complain about, neither of which are the case.
This was going to be a longish rant about various things I don't enjoy about Unix programming, but it was promped by one pesky bug, and I'll just stick with that one for the time being.
The "Note to Self" of the title is this: It's bad for one singleton object to rely on a pointer to another singleton object, thus relying on the hope that the second will be around for the entire lifetime of the first object, and then some. If you do decide to do this, at the very least don't use object #1 while the app is cleaning up and exiting as the result of an exit() call. And if you abolutely have to do that, at least don't have multiple threads running at the time. Otherwise you'll quite possibly stumble into the same situation I did recently. Thread #1 wants to use singleton #1, which performs some filesystem utility stuff. Unfortunately, we've gotten a SIGTERM just now, and thread #2 is in the middle of an exit() call. As part of that, global and static objects get destructed in some unknowable compiler or machine defined order that the books all warn you to never, ever rely upon. Thread #2 destructs singleton #2, which would be fine if singleton #1 didn't subsequently try to use a pointer to singleton #2. Pure virtual function call, yada yada yada, SIGABRT, core dumped. Feh.
At least that's what I've been able to reconstruct from core files sent to us by a surly user. At least I can take pride in the fact that not one line of the offending code was written by me. It would've never occurred to me to write it that way.
I don't have my Antipatterns book handy to verify this, but an unidentified coworker seems to have discovered a brand new one. Yikes.
Wednesday, March 15, 2006
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment