Saturday, March 10, 2012

Recovering from repeated crash at Firefox (11 Beta 7) start-up

Quick Solution
 
Delete
  • session.js
  • sessionstore.bak
  • files inside sessions folder
from inside your Firefox profile directory. Follow this page to find out where you profile directory is located.

How I found what caused the crash
 
After quite few "unresponsive script" error inside Firebug 1.9.1 (mostly on LifeHacker.com and Boston.com) and repeatedly selecting "Stop Script" with no apparent benefit, I chose to kill Firefox from Windows Task Manager [1]. For those who don't know that it is - try pressing "CTRL+Shift+Esc" on your keyboard or just right-click on your task-bar and select "Start Task Manager". It looks like this:


I didn't realize the fun is just about to begin. To my surprise, upon the next restart Firefox started as usual and but quickly crashed. It kept happening much like flashing the Firefox's main window for a second or two and boom, it crashed! This behavior was already a good indication that it might be caused by a corrupted file, most probably a SQLite [2] database and this must have happened due to my killing Firefox forcefully using the Windows Task Manager. So, I started to digging around for a resolution.

First, I tried to start Firefox in "Safe Mode" with all add-ons disabled as suggested here [3] with "-safe-mode" flag. It didn't work! From my all previous experience, Firefox's safe-mode always seemed the best way to solve crash related problems, buggy extensions and add-ons. But, in this case it kept crashing even in safe-mode.

Then, I tried to open Firefox in "Private Browsing" mode with the "-private" flag. On Windows 7 (I guess on Vista too), this can be done with right-clicking the Firefox task-bar icon and selecting "Enter Private Browsing". Interestingly, Firefox was able to start in this so-called incognito mode! This was another strong hint that some files must be corrupted in my "Firefox Profile Folder" [4].

To try the theory, I closed all running instances of Firefox and I renamed Firefox's "profiles.ini" [5] to "profiles.ini.bak" to force Firefox into creating a fresh new profile. I started Firefox and it successfully created a new profile in my "%APPDATA%\Mozilla\Firefox" directory. The new profile directory was named "an9pz0cj.default".  By the way, if you are like me and you love your Firefox's plethora of customized settings and very longs list (77 in my case) of plugins only to profoundly avoid reinstalling them, don't forget to regularly backup your profile directory. My default previous profile directory was called "yn0z15ze.default" and I backed it up in a RAR archive.  After generating a fresh profile, which also generated a new profiles.ini, I copied all files (not folders, I decided to try them in the second iteration) from "an9pz0cj.default" and pasted them in "yn0z15ze.default". Windows 7's copy and paste is great. It kept showing me all the conflicts due to size, date-time of source and destination files. I kept the list of the files where the file-size was different. In my case, the list looked like the following:
  • cert8.db - SSL certificates are stored here.
  • chromeappsstore.sqlite -- HTML5 local data store.
  • content-perfs.sqlite -- Individual settings for pages.
  • permissions.sqlite -- Permission database for cookies, pop-up blocking, image loading and add-ons installation.
  • search.sqlite -- Information about search plugins
  • sessionstore.bak -- saved sessions.
  • sessionstore.js -- saved previous session
  • signons.sqlite -- Encrypted saved passwords
  • TestPilot.log --  Log file.
  • webappsstore.sqlite -- DOM local storage.
I Google'd up on the name of the files and got a rough idea of what they are meant for and how they are used inside Firefox. So, at this point I my preferred profile "yn0z15ze" is working but with some default files which means I must have lost some data, may be some customizations too as the list contains cert8.db, search.sqlite and signons.sqlite etc.

Now comes the final part - I have to test each of the files above one by one and figure out which one was causing the crash. As you may have gotten the idea already - I love my Firefox and my customizations. So, I wanted to make sure that I lose minimum amount of data due to the crash.

So, I renamed my previously moved "profiles.ini.bak" to "profiles.ini". By the way, profile.ini looks like below:
[General]
StartWithLastProfile=1

[Profile0]
Name=default
IsRelative=1
Path=Profiles/an9pz0cj.default
Default=1
So, I could have just replaced "an9pz0cj" with "yn0z15ze" and saved profile.ini to achieve switching between profiles. Anyways, I did that anyhow and started copying files as shown on the bulletted list above from  "yn0z15ze" RAR archive to now running "yn0z15ze" with some fresh files of "an9pz0cj". I kept restarting Firefox each time to check if Firefox is crashing. After a few iterations of stopping Firefox, copying fresh files into "yn0z15ze" and restarting, I stopped at "sessionstore.js". I copied this file and Firefox crashed!

Wow, so now I know which file was causing my Firefox to crash! Also, now that I know this file only contains a list of my tabs which I was browsing before the very initial task-manager kill, I can safely disregard this file now ;). Phew, so the case is solved. If you happen to come across a situation like mine, try deleting the "session.js" and/or "sessionstore.bak" and/or files inside "sessions" folder. It's weird that even in Firefox's safe-mode the problem managed to persist. Time for a bug report I guess :). Hope you find it useful.

[1] http://en.wikipedia.org/wiki/Windows_Task_Manager
[2] http://en.wikipedia.org/wiki/Sqlite
[3] http://kb.mozillazine.org/Safe_Mode
[4] http://kb.mozillazine.org/Profile_folder_-_Firefox
[5] http://kb.mozillazine.org/Profiles.ini_file

Friday, January 20, 2012

GTK Theme is not being followed by all GTK Applications (on LXDE)

On my LXDE (Ubuntu Oneiric 11.10) setup, I have recently discovered that not all GTK applications are getting themed with the GTK theme (Adwaita) of my preference. 

My first obvious attempt was to reset theme with LXDE Menu > Preferences > Customize Look and Feel. I set Adwaita in the "Gadget" tab. That Didn't help. Many "sudo" applications along with some other normal GTK-3.0 applications (e.g. evince) stills stayed un-themed.


Ubuntu repository apparently has two tools to set GTK-2.0 themes:
  1. gtk-chtheme
  2. gtk-theme-switch
Gtk-chtheme is much better in my opinion. So, I gave it a shot and selected "Adwaita" from the list of installed GTK theme. Still no change.

Then as a last resort, I wanted check which GTK theme files are actually being accessed during the initialization of the applications. For that, I started Evince from the console with strace as below:
strace -e trace=access evince 2>&1 | less
After a quick checking through the output it was obvious that my GTK-3.0 themes are not being found by the applications and the theme files are being searched for both in:
  1. /home/USER-NAME/gtk-3.0
  2. /home/USER-NAME/.config/gtk-3.0
On Ubuntu, GTK themes are installed in /usr/share/themes. So, the quick, easy and clean solution to the problem was to create a sym-link to the GTK-3.0 theme of my preference as shown below:

ln -s /usr/share/themes/THEME-NAME/gtk-3.0 /home/USER-NAME/gtk-3.0
ln -s /usr/share/themes/THEME-NAME/gtk-3.0 /home/USER-NAME/.config/gtk-3.0

After creating the sym-links, I restarted Evince and voila! it's perfectly themed with Adwaita now.


P.S.
If you ware selecting another themes other than Adwaita, make sure /usr/share/themes/THEME-NAME/gtk-3.0 actually exists. Not all themes in /usr/share/themes/ are GTK-3.0 compatible and they will miss the gtk-3.0 directory inside the theme folder.

Friday, November 11, 2011

Compile NS-2.34 and 2.35 with GCC-4.6

I stumbled into the compilation issue after upgrading to Ubuntu Oneiric 11.10. The error occurs in "mac-802_11Ext.h" saying something like the following:
mac/mac-802_11Ext.h: In member function 'u_int32_t PHY_MIBExt::getHdrLen11()':mac/mac-802_11Ext.h:175:19: error: expected primary-expression before 'struct'mac/mac-802_11Ext.h:175:41: error: 'dh_body' was not declared in this scopemac/mac-802_11Ext.h:175:51: error: 'offsetof' was not declared in this scope
I found the solution in Ubuntu's patched version of NS-2.35-RC6. The direct link to the patch is here: http://launchpadlibrarian.net/74445224/ns2_2.35~RC6-4_2.35~RC6-4ubuntu1.diff.gz

It's really simple. All you have to do is to add #include cstddef as shown below:
#ifndef ns_mac_80211Ext_h
#define ns_mac_80211Ext_h
#include cstddef
#include "marshall.h"
#include "timer-handler.h"
 Now, NS-2.34 should compile fine with GCC-4.6. Enjoy your simulation!

P.S. BlogSpot is simply terrible for posting code snippets. For clarity, here's a screenshot of what the code should look like.

 

Friday, October 21, 2011

Google Chrome (Chromium) font anti-aliasing is wrong on LXDE (L)Ubuntu Oneiric (11.10)

The solution was to add the following in the ~/.fonts.conf 

xml version="1.0"?>DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>noneconst>
  edit>
 match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>truebool>
  edit>
 match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslightconst>
  edit>
 match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>truebool>
  edit>
 match>
 <match target="font">
   <edit mode="assign" name="lcdfilter">
    <const>lcddefaultconst>
   <edit>
 <match>
</fontconfig>

One may have to play around with the "hintstyle" to get it right. The available options are:
  • hintslight
  • hintmedium
  • hintfull
  • none

Wednesday, October 19, 2011

Ubuntu Oneiric (11.10) DPKG error removing old Linux kernel

I stumbled into another trouble removing my obsolete packages after upgrading into Ubuntu Oneiric 11.10 with Linux kernel 3.00-12. The problem is with removing the old 64bit kernel 2.6.35-24. The Debian package name is 2.6.35-24. The error I got is following:
[13:41:34] user@machin:[/var/lib/dpkg/info]$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages will be REMOVED:
  linux-image-2.6.35-24-generic
0 upgraded, 0 newly installed, 1 to remove and 31 not upgraded.
1 not fully installed or removed.
After this operation, 139 MB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database ... 248250 files and directories currently installed.)
Removing linux-image-2.6.35-24-generic ...
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-24-generic /boot/vmlinuz-2.6.35-24-generic
update-initramfs: Deleting /boot/initrd.img-2.6.35-24-generic
run-parts: executing /etc/kernel/postrm.d/zz-extlinux 2.6.35-24-generic /boot/vmlinuz-2.6.35-24-generic
P: Checking for EXTLINUX directory... found.
P: Writing config for /boot/vmlinuz-3.0.0-12-generic...
E: /usr/share/syslinux/debian/extlinux: No such file or directory
run-parts: /etc/kernel/postrm.d/zz-extlinux exited with return code 1
Failed to process /etc/kernel/postrm.d at /var/lib/dpkg/info/linux-image-2.6.35-24-generic.postrm line 328.
dpkg: error processing linux-image-2.6.35-24-generic (--remove):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-2.6.35-24-generic
E: Sub-process /usr/bin/dpkg returned an error code (1)
The highlighted lines told me the error is caused by the postrm script called zz-extlinux located in /etc/kernel/postrm.d/. I don't know how I managed to have extlinux installed on my system. If I am not mistaken booting is still managed by grub-2. So, I decided to remove both extlinux and linux-image-2.6.35-24-generic. But, since my DPKG is already going crazy removing linux-image-2.6.35-24-generic and failing on zz-extlinux, I have to remove the old Linux image first. I quickly patched the zz-extlinux script with an "exit 0" at top followed by an "sudo apt-get -f install". One could also make it non-executable as following as a solution, followe:
sudo chmod -x /etc/kernel/postrm.d/zz-extlinux; sudo apt-get -f install
This solved my problem removing the Linux image. Now, I guess one can also remove extlinux considering Grub-2 is the bootloader.
sudo apt-get remove --purge extlinux