Posted in February 2010

Thunderbird Bug Fix Lab

Dave had everyone in the class working on the Thunderbird Bug Fix Lab on Thursday.

The lab should give us first-hand experience in creating, fixing and submitting a patch.

The first thing I did was create an account on Mozilla’s fake Bugzilla. Then I filed a dummy bug.

When I went to file the bug, I got hit with a ton of form fields. I got a little confused, so I went over to the real Bugzilla to observe how others file their bugs. Dave mentioned at the start of the semester that people who are not developers often file bugs. If I wasn’t a programming student, I would have looked at those form fields and hit the back button. I ended up writing in a summary and description, leaving everything else blank or at its default. Now that I think about it, the description I wrote is pretty ugly.

When I tried to do a debug build of Thunderbird that night, I was met with an error:

WARNING: NS_ENSURE_TRUE(compMgr) failed: ... nsComponentManagerUtils.cpp, line 90 WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80040154: ... Could not initialize nsContentUtils: \'Error\'

Two Screen Shots. The first one is a warning I missed the first 2 times I ran Shredder (scrolls by too fast). The second one is of Shredder right before it died on me. Here’s that lovely error:


WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80040154: file c:/comm-central/mozilla/content/base/src/nsContentUtils.cpp, line 383
###!!! ASSERTION: Could not initialize nsContentUtils: 'Error', file c:/comm-central/mozilla/layout/build/nsLayoutStatics.cpp, line 168

and the only reason I typed that out is so Google can find it.

I probably should have started by searching Bugzilla, but habit sent me to Google. I wanted to find anyone who had encountered this bug. Maybe it’s because I was using nsContentUtils.cpp, nsLayoutStatics.cpp, and variations of the two in my search criteria. I was taken to Planet CDOT, where Jianming blogged about encountering the same error. I was still unable to find out how to fix the problem. Actually, I feel really lucky that I found Jianming’s blog. I bet there are others blogging about the same error. I also bet they posted screen shots of their errors. Google won’t find those posts for me.

I changed my approach by google-ing for a list of mozilla’s mailing lists. I wanted to search any Thunderbird-related mailing-list archives. I went through dev-apps-thunderbird, feedback-thunderbird, feedback-thunderbird-prerelease, and support-thunderbird. At the time, I didn’t find anything.

Actually, it’s been 4 days since I originally searched those Thunderbird mailing lists. As I was writing this post, and creating a link to dev-apps-thunderbird, I found this post by Mark Banner (Trunk Builds – current failures). It’s a nice surprise.

With no success in the mailing list archives, so I finally went after Bugzilla. Again, I couldn’t find anything.

I didn’t know where else to search, so I called it a night.

The next day, I went to check up on CDOT to see if Jianming had any luck with the error. Instead, Andor Salga’s “(Not) Building Minefield” came up. When his build wasn’t working, he checked Tinderbox. It was one more place to search, so I went with that. Turns out Thunderbird’s ‘WINNT 5.2 comm-central check %’ is burning. At least the problem isn’t me.

There’s a link right above the chart, leading to Bug 546913.

Turns out there was a bug filed regarding nsContentUtils.cpp and nsLayoutStatics.cpp. It was filed on the 18th (a week earlier). I guess I suck at searching. Mark Banner, the same guy who posted on dev-apps-thunderbird, is the one assigned to the bug. Best part is, I think he’s almost done with his fix. He had a patch that was waiting for review. When I checked Tinderbox again (today) I see that the trunk is building (1h and 5 minutes have elapsed).

For now, I’ve been reading zenit’s Real World Mozilla Incremental Build Lab and Andor’s post on Patches. Trying to figure out how to apply patches and what not. If the trunk turns green again, I’ll try applying Mark Banner’s patch myself. I’ll need the practice anyway.

For now, I’ll keep an eyeball on Tinderbox while I read up on patches. and ANTLR.
I haven’t given up on that.

New Plan of Attack – ANTLR grammar

I did some reading last night. Yes, the Language Implementation Patterns book, but that’s not what I want to talk about.

I went through wk 5s’ class reading ‘Code Reading: An Open Source Perspective’ – Chapter 11. Curiosity + avoiding studying for a mid-term.

If I accessed it via the wiki link, I wasn’t able to log in and view full pages. I had to log into Seneca libraries > ebooks and search from there.

When I wasn’t falling asleep during the reading, I was taking notes and plotting against this semester’s ANTLR bug.

Here is the plan and the ideas from whence it came:

Plan: Locate Processing‘s ANTLR based Java grammar. Use it to model the Javascript grammar.

So what happened in Chapter 11? Summary + commentary:

There’s this dude (the author). He wants to add a new function ‘PHASEOFMOON’ to an sql database of 34,000+ lines of Java source.

First thing he does is try to get an overview of the system. He finds an outline of top level directories in index.html.
—>After seeing Dave use Mozilla’s mxr so much, I started to focus on the benefits of ‘jumping into code’. I forgot the most obvious of starting places (like index.html or a root directory) is actually a great place to start. If developers wanted you to find some information, that’s the perfect place for them to put it.

Next he builds the system. This way he knows any future warnings or errors will be his own doing.

His plan of attack is to search for documentation for functions similar to the one he’s trying to add (he’s looking for ones with similar attributes and types). He finds a few, selects the one with the most uncommon name (he calls it ‘using plain text-matching effectively’), and plans to use it as a model for his own function. This would keep everything uniform and help with readability and code maintenance. This is why I’m eyeballing the Java grammar now.

He also gets frustrated with a lack of comments in the code. You sort of feel his pain.
—>Let me rant. About ‘potm’. What the heck is ‘potm’? It’s the name of a function the author runs into. It’s an acronym for ‘phase of the moon’. That’s just nasty. It doesn’t even register in my brain as something to look into if I’m skimming lines of code. What’s worse is that I’m pretty sure I’ve coded assignments using acronyms for variables. I am officially ashamed.

The author also reads code backwards. Terence gives his readers a tip in Lang. Implementation Patterns: start with the end/outcome you want and work backwards from there. I’m thinking this backwards thing must have some merit to it.

My favourite part. The author runs his code and gets an error. So he searches the code for the error’s implementation. My mind imploded.

There’s how you know I grew up on Windows and closed-source applications. I’m used to getting an error and accepting it. That’s after pasting it into Google and praying someone else knew how to fix it. I realized this somewhere in week 2 of OSD600 and I keep having to remind myself because it doesn’t come naturally yet. Google-ing the error used to be the only way, I like the thought of getting to the error itself and finding out what its problem is.

/me writes a mental note.

Couple more things, don’t worry, my brain imploded so I can’t write for much longer.

There’s a lesson on maintaining code. Remember to update the change log with a comment, or create a README file in the source root directory indicating any modifications made.
—>After meeting ‘potm’ I would take the time to do this. For the sake of humanity.

3 more things I learned. I’m gonna do this in point form:

  • Code reading is opportunistic and goal-directed. That sounds pretty cold. But okay.
  • Use the build process, and execution of the system, to find code that needs attention. This is helpful in locating other files or functions that need modification after the main fix is written.
  • If you run into code that is very difficult to understand – ditch it. This is the author’s ‘breadth-first strategy’. Code-reading problems can be attacked from many angles, just keep going until something gives.

There’s the end of the list. I’m gone. Back to studying.
‘potm’.

Learning ANTLR – Language Implementation Patterns

The first thing I learned about ANTLR: the best place to start is with Terence Parr’s books.

I ordered them online last week, and they finally came in the mail on Monday. I was in bed when there was a knock at the door – I knew it was the mail man with my ANTLR books. I couldn’t kick my blankets off fast enough.

I said I would start with Parr’s second book in my Initial Project Plan. One of the problems I listed in my project plan is my learning style. I planned to only read the chapters of the book I need. So here’s the problem:

The book lists 4 language application categories:

  1. Readers – builds a data struct from input streams
  2. Generators – walks an internal data struct & emits output
  3. Translators – a combined reader & generator
  4. Interpreters – reads, decodes, executes instructions

What I need to write is a translator(#3). Which means I need to write a generator(#2), which won’t work without the internal data structure created by the reader(#1). Since I have no prior language application experience, I’ll be reading most of this book – starting at the front and going from there.

When I started with the front of all fronts – the Preface – I was still looking for the ANTLR community. Where are they besides the mailing lists and their wiki? Turns out this book has a little forum. Only 12 topics and 32 posts, but the last post was written 10 hours ago and some of those topics have 400, 600, 900 + views. Good to know it’s alive.

The preface also mentioned ANTLR’s support page. Which I’ve visited before, but I must have missed almost EVERYTHING they had written on there. It’s like finding gold:

I’ll be back after I read a few chapters.
Toodle-loo for now!

Building Firefox

I disappeared last week. I was taking a 5 hour nap on Tuesday, when I should have been in class. Guess I shouldn’t do that again – I missed Dave’s class on compiling Firefox.

Wednesday I was back in school. I spent a few hours in TEL’s Open Lab, downloading all the the tools I would need to build Firefox later that night. I needed to have it built (or try to have it built) for Thursday’s class.

I used this task as an excuse to take over my mom’s new laptop >=]

The list of goodies I secured from the TEL lab and the order I installed them:

0 – Alcohol52% Free Edition – I use a virtual drive to install all of my .iso files. I love the name and it’s wonderful.

1 – Visual Studio 2005 Pro – decided to go with ’05 because it was marked by Mozilla as ‘official‘. Seneca students can download it (2 .iso files) from ACS

2 – VS05 Team Suite Service Pack 1

3 – Microsoft Hotfix – cures a linking problem

4 – Windows 7 SDK – went with the .iso download so I could use Alcohol52% again. I didn’t know which one to choose, so I tried the first one: x86. It didn’t work right off the bat, so I downloaded AMD64. It worked perfectly. <3 Download takes 20 minutes per .iso in TEL's Open Lab.

5 – Mozillabuild <– that links right to the mozillabuild download

This is as far as I got before Thursday’s class. I started installing the files Wednesday night, fell asleep during the VS05 disk 1 install, and again during the Windows 7 SDK install. I finished installing Mozillabuild right before I left for class.

Monday, I finally got back to the Firefox build. I followed MDC’s ‘Simple Firefox build‘ page

run:
c:\mozilla-build\start-msvc8.bat

and a lovely window appears. Ensure your path doesn’t have any spaces in its name:
cd /c

get source code:
hg clone http://hg.mozilla.org/mozilla-central/

got an error:
requesting all changes
adding changesets
adding manifests
transaction abort!
rollback completed
abort: connection ended unexpectedly

Google: 5 seconds later I was at Konstantin’s blog. Apparently I needed to grab a LAN cable. But I was cozy in my room, on wi-fi. So I ran the command again:
hg clone http://hg.mozilla.org/mozilla-central/

and again:
hg clone http://hg.mozilla.org/mozilla-central/

and again:
hg clone http://hg.mozilla.org/mozilla-central/

I was about to search for the LAN cable when that 4th time succeeded. I am delighted.

continue:
cd mozilla-central

create the mozconfig file, I’m going with the debug build (1.5GB larger than the release build):
echo '. $topsrcdir/browser/config/mozconfig' > mozconfig
echo 'mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-debug' >> mozconfig
echo 'ac_Add_options --enable-debug' >> mozconfig
echo 'ac_add_options --disable-optimize' >> mozconfig

build:
make -f client.mk

I don’t know how long the build took. I went off for 40 mins to go eat, came back, and realized the laptop had gone to sleep …. karma?

When the build did finish, this line didn’t work:
objdir-ff-release/dist/bin/firefox

I thought firefox.exe wasn’t created. Turns out my directory was named objdir-ff-debug, not objdir-ff-release. Before I realized that, I had gone to Google, thinking there was a problem with my build.

I found a blog post by Simon Jung. His post is excellent – and very detailed. He wrote a note on Minefield:

If there is a current Firefox session running, Minefield will open another window, it won’t actually run Minefield.

After I fixed my path:
objdir-ff-debug/dist/bin/firefox

A window popped up – and looked exactly like the Firefox/google search home-page-thingy. It even had the Firefox icon. How suspicious. Turns out I had minimized my Firefox window so it was still running when I ran Minefield. I remembered what Simon Jung had posted, closed the Firefox windows and tried again. This time:

Minefield
The page was huge, so I tried ‘Ctrl + -’ to shrink it …. and I broke it already.

Follow

Get every new post delivered to your Inbox.