Thursday, January 18. 2007'Safe' iterators
A few years ago, while working in the RTA, I ran into a reasonably complicated problem where a list would be traversed at two portions of the code at the same time. That is, say that I have a list A which I am traversing and performing actions on each of the contents in the list. I have reached object X and am performing an action on it. The effect of this action is to destroy object X+1 and remove it from list A. However, the iterator on list A has already grabbed a pointer to the next object (X+1), and when the loop attempts to access the memory address of X+1, it is accessing invalid memory which may cause a dreaded segmentation violation.
This problem was quite difficult to debug and eventually I managed to produce a test case which demonstrated the problem. The programming language at the time was C++, and the test case looked like this: #include <stdio.h> #include <list> using ::std::list; void pathologicalCase ( list < char * > &rList ) { for ( list < char * >::iterator aOuterNext = rList.begin(), aOuterIter = rList.begin(), aOuterEnd = rList.end(); aOuterIter != aOuterEnd; aOuterIter = aOuterNext ) { ++aOuterNext; printf ( "Outer is %s\n", (*aOuterIter ) ); for ( list < char * >::iterator aInner = rList.begin(), aInnerNext = rList.begin(), aInnerEnd = rList.end(); aInner != aInnerEnd; aInner = aInnerNext ) { ++aInnerNext; printf ( "Inner is %s\n", (*aInner) ); if ( 0 == strcmp ( *(aInner), "String B" ) ) { free ( *(aInner) ); rList.erase ( aInner); } } } } int main ( int argc, char **argv ) { list < char * > aList; aList.push_back ( strdup ( "String A" ) ); aList.push_back ( strdup ( "String B" ) ); pathologicalCase ( aList ); } It has taken me quite some time to get the 'geshi' syntax highlighter to display the above code block correctly, so I am going to stop here for now and then post the C++ code I used to 'fix' the above problem. Blogging
I currently work for a high-tech startup called Corvil Networks. We are developing a product which is sold by Cisco as the Cisco Bandwidth Quality Manager. It's a great company to work for, and we have high hopes for version 3 of our product (in it's 3.0, 3.0.1, 3.1 etc guises). The basic software architecture of the BQM is 4 components: A C++ daemon which handles packet processing (called 'probed'), a C library which performs statistical analysis of packet data (called the 'CDK'), a Java library which handles data aggregation and a Web front end written in Java/JavaScript. All of this is backed by a Postgres database to store both configuration data and analysis data.
I am part of the team responsible for the 'probe' part of the product, and as we have recently finished the '3.0' product, we are now starting on defining what exactly the next version will look like, and what additional features we will be adding. The process for doing this is that the Product Management (PM) team provide us with Project Requirement Documents (PRDs), we analyse them and figure out how the PRDs can be implemented. The formal response to a PRD is a Functional Specification (FS) which defines what the new features will be, roughly how they will be implemented, and how they will look like to the end user (whether the user uses the Command Line Interface (CLI) or the web front-end (GUI)). I am the team lead on writing two of these specifications, and am the probe team's representative on two others. When I started the first functional specification, I found that starting with a blank white screen in front of me somewhat intimidating, so I did a web-search for 'Functional Specification' to see if someone had some useful hints or tips about the process of writing a Functional Spec. One of the results was 'Joel on Software', someone that Caolan has often recommended that I read. I found his musings on Functional Specifications useful, and decided to follow his recommendation that the best way to get better at writing, is to write. Hence my new resolution, which I will no doubt break in the near future: to write at least one Blog entry every week! Wish me luck! Wednesday, June 14. 2006BT Ireland
Just over a year ago, I returned from Australia to Ireland, and resolved to treat myself to all of life's little luxuries which just aren't available to you when your house consists of a rucksack. The first of these was easy: I could leave my tooth brush next to the sink over night and be reasonably sure it would be there the next day. The second should have been just as easy: to get broadband.
Unfortunately, nothing in Ireland is easy. I did some research and discovered that BT Ireland offered the best deal. My sister, who lives in London, warned me that BT were a terrible company to have to deal with and had little or no concept of customer service. I blithely ignored this good advice, deciding that BT Ireland was a seperate company trying to break into an incumbent's market, rather than the incumbent, and that therefore surely they must have a better concept of customer service.Boy, was I wrong. I ordered my broadband on the 13th of July, and was assured by the salesman that there was no need for me to upgrade from my expensive, charged per minute, dial-up to their flat-rate offer, as my broadband would be operational within two weeks. Three weeks later, I emailed them and asked for some hint as to whether they had even received my offer. I was assured that they had, and I could expect to be up and running within 3-4 weeks. Three weeks later, BT rang and said that they could get an engineer out to look at my line in three week's time. I said 'OK, great, so he'll get everything up and running then will he?' 'No', they said, 'He'll just check your line, we'll send out the modem 3 weeks after his visit'. This would have meant a wait of almost three months from the time I ordered to the time I had operational broadband. Needless to say, I quickly cancelled my order and ordered broadband max from NTL instead. It was installed and operational within three days of my order, and the first three months were free for a 3MB download speed. I was pretty happy with that! However, three weeks later, I got a letter from BT to tell me that they had cheerfully taken over my phone line from Eircom and that I was now their customer. I rang them immediately to ask 'what the!', but was told that I wasn't able to cancel my order online, and I had to cancel it in writing. This, despite the fact that they had confirmed my cancellation by email and the cancellation was still visible on their 'customer care' website. I wrote and sent a letter of cancellation the same day, and once again thought the matter was closed. Nope. 2 months later (in mid-November now), they direct debited €122.78 out of my account, without even a little note to explain why. I rang them immediately to complain and was fobbed off, so I rang the bank and asked them to reverse the direct debit, which they couldn't, so I had to settle for merely cancelling it. I then wrote a stinker of a letter, requesting that they refund my money immediately. I got no reply, and so I started to investigate other options, such as Small Claims Court etc. Then, in January, I got a letter from a debt collection agency telling me that I owed BT a further €58. I was a bit surprised, so I wrote them another letter requesting my money back, and also sent a complaint to their regulator, ComReg. No replies from anyone, and then, just when I had gotten all of the forms filled out for Small Claims Court at the beginning of may, I got a cheque from them in the post for the princely sum of €115.75. I'm not entirely sure why they kept €7.03, but at this point, I don't really care. I just know that BT Ireland sucks. Tuesday, January 10. 2006New Blog software
A few things have collided to inspire me to fix up my blog. These are:
1. Susan printed out all of the blog entries from our trip around Australia & New Zealand and had them bound into a book, as a present for my 30th birthday! 2. She later told me that she saw lots of references to pr0n, gambling etc on the blog and was wondering if I knew about it. I told her that was impossible, and that the machine she was using must have been trojan'd or something. 3. I accidentally added a mate from Australia (Tim Gould) to a Skype chat session with my sister. He got back to me this morning and when I inquired about his upcoming trip to Europe, he pointed me at his website. From there, I found my way to his blog. The first two things from above inspired me to dig up my blog and take a look at it for the first time in about six months. Indeed, it was liberally coated with references to all kinds of spam, and additionally was reporting many errors from broken MySQL tables. I eventually fixed it up, but it was a painful experience and prompted me to re-evaluate my choice of 'Blog:CMS' as a blogging tool. When I originally chose it, I had limited time as I was setting it up on my second last day of work at the RTA in Australia. As a result, I didn't have a huge amount of time to evaluate the various blogging alternatives. When I was setting it up, I had many problems with it, and had to manually edit and hack alot of stuff to get it to work, and also had to pull out or comment out various blocks of functionality I didn't need or want. Yesterday I discovered the reason for all of this! Blog:CMS basically consists of a number of open source projects badly hacked together by some loser called Radek Hulán. The blog component is based on 'Nucleus' (http://www.nucleuscms.org/). I spent some time comparing 'Nucleus' with 'Blog:CMS' and decided that I would change to Nucleus as it seemed to be better supported and didn't include the kitchen sink. I did some web-searching for a conversion tool, and found lots of posts by Radek blowing his trumpet (for example), and was generally repulsed by his comments and behaviour. He seems to think that size is everything and continuously comments how much bigger his fork of Nucleus is - my theory is that he is compensating for deficiencies in another department. At any rate, no decent conversion tools turned up, so I manually did the changeover from Blog:CMS to Nucleus. It was reasonably pain free, just involving some hacking out of the blog_cmsnucleus tables into the nucleus ones, the only complicated bits being that I had to delete some columns first. This done, my blog then ran on Nucleus! Hurray! It was a much cleaner design than Blog:CMS and I went to bed, happy. However, this morning, after my conversation with Tim, I noted that his blog was based on Serendipity, so I was inspired to try that out and see how it had matured since my last look at it. I was very impressed and it seemed alot cleaner and more user friendly than either Nucleus or Blog:CMS so I decided to switch to it. After setting up, I just clicked 'Import data', and it imported all of my old blog entries from Nucleus in seconds, and I was setup! The spam I had seen in Blog:CMS came from a combination of Comments and Trackbacks, so I was heartened to see Tim's comments here about how Serendipity handles this, and hopefully this won't happen again. Hurray!
(Page 1 of 1, totaling 4 entries)
|
Calendar
QuicksearchArchivesCategoriesSyndicate This BlogBlog Administration |
|||||||||||||||||||||||||||||||||||||||||||||||||

