Offspring on (check)
Green tea with brandy (check)
So hello ineffaceable people! It was an amusing day, after a sleepless night (once again), as most of you have experienced such feeling after a long long (looong...) day, and night for that matter, of work followed by "early" wake up. It is like you are in one of those movies where the main character just wakes up, everything is blurry and there's almost no recollection of what happened last night. Hit pretty fast by the strong cup 'a' coffee you've just made for yourself with the ingenious idea that it will straighten you, but alas you find that concentration and focus are not even remotely present. (by the way did you know that there are missiles called ALAS ? http://en.wikipedia.org/wiki/ALAS_missile I sure did not).
So lets get to it then, shall we ? (Parts a bit technical, skip if bored to death.)
There are 2 parallel stories that developed, one involving my iPhone doing things that probably even Apple won't believe and the second one involving one nefarious bug in a small software.
Lets begin with the iPhone story: I'll try to structure it as much as I can since I think that the states the phone went through could be easily represented by a graph which could logically explain why/what made it go POO.
I started by breaking free my girlfriend's phone and thought "hmm, why should mine be still locked ? Only because I have an iPad baseband on my iPhone and a twisted version of iOS which was barely put together shouldn't deny me of the pleasure of playing with Cydia, oh and yes - my wi-fi is out of order (hardware problem) too.." Of course everything broke down, iTunes wouldn't recognize that there was a device connected, as a matter of fact none of the jailbreak/recovery mode/DFU mode programs would recognize it.. But lets not get our hopes down, I started fiddling with the bootstrap software and was finally able to reconfigure it to boot into Recovery mode again, afterwards iTunes started spilling errors (1600 - unknown error [?!]), and because of the iPad baseband I couldn't just update/fix it through iTunes so I had to fix it using the "pirate" software (you think of another term at this hour..), it had already loaded 2 different exploits which should've allowed jailbreaken firmware to be uploaded, so I went on a limp and did the iPad baseband reinstall procedure with a new custom firmware (making use of the new exploits) and was able to go from Dead mode -> DFU Mode -> Recovery Mode -> Standard firmware -> DFU Mode -> Jailbroken/custom firmware -> Incompatible Cydia/iOS and packages on top as a result.. The plan was to use some tool called Cyder to install Cydia software through the PC (without the need for wi-fi), but of course with incompatible versions it all went to a very dark place very fast. I'll stop here because I started to bore myself with my own story and continue with the second one which developed in parallel (in the next window on the taskbar)..
The bug with the software was trivial, but manifested in a rather interesting way. Here's the quick overview: a multi-threaded program which services some descriptors, a long forgotten static descriptor variable (unused) and a select syscall. If this doesn't ring any bells yet, here's what happens next: since the software doesn't handle the select syscall well and upon receiving a descriptor with id = 0 it just selects it, since it doesn't use STDIN, if you've started it in background and still logged on there is no problem, BUT once you quit and the descriptor gets closed select should return EBADF (according to the manual of select(2), and /usr/include/errno.h says error 9 == EBADF). Now put that in a room with improper select return value handling and you've got yourself a software which behaves normally when started but upon exit goes to 100 % (good it's only 1 thread doing the selects) CPU usage. Of course easily "debuggable" issue, if you even get to a debugger, the cause is pretty logical, but it's rare to hit such bug nowadays, which makes it fun :-) Moral of the story ? Don't leave unused variables behind or one day they'll haunt some programmer dealing with your mess (or you for that matter) !
'nough said, going to glue together some parts for a design show model now,
Haunt you soon!
P.S. For the sleeping beauties Day hard is mildly related to Die hard, now the question is have you watched it ? If not, you are not of age to read this blog, so shoo!