bug

Watch for locale settings

I have had utterly frustrating bugs running Ubumtu 8.04 Hardy Heron.

The symptoms:

  • When entering into visual mode in vim, it SEGFAULT-ed. But only if the vim instance was trying to communicate with the X server (-X was not present).
  • Graphical Java apps (Swing, AWT and even applets) failed to use a keyboard layout different from the default one. Also 2nd and 3rd level modifiers got ignored.

I found that changing all ".utf8" suffixes for entries in /etc/environment.conf to ".UTF-8" resolved them. But why does locale -a list the locales with the ".utf8" suffix?

My current config:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/czigola/bin"

LANGUAGE="en_US.UTF-8"
LANG="en_US.UTF-8"

NLS_LANG="en_US.UTF-8"

LC_CTYPE="hu_HU.UTF-8"
LC_COLLATE="hu_HU.UTF-8"
LC_TIME="hu_HU.UTF-8"
LC_NUMERIC="hu_HU.UTF-8"
LC_MONETARY="hu_HU.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="hu_HU.UTF-8"
LC_NAME="hu_HU.UTF-8"
LC_ADDRESS="hu_HU.UTF-8"
LC_TELEPHONE="hu_HU.UTF-8"
LC_MEASUREMENT="hu_HU.UTF-8"
LC_IDENTIFICATION="hu_HU.UTF-8"

TZ='Europe/Budapest'

EDITOR=vim

# fixing bugs...
LIBXCB_ALLOW_SLOPPY_LOCK=1
INTEL_BATCH="1"

JAVA_HOME="/usr/lib/jvm/java-6-openjdk"
JAVADIR="/usr/lib/jvm/java-6-openjdk"

Fixing high load cycles for hard disks in Ubuntu

The most common hard drives ship with APM power saving parameters (hdparm -B option) that causes frequent load/unload cycles. Some users also experience overheating.
Operating systems usually set acceptable parameters for this, avoiding so early disk deaths.

Not so Ubuntu >:( ...

https://bugs.launchpad.net/ubuntu/+source/...
https://wiki.ubuntu.com/DanielHahler/Bug59695

It just leaves the default values untouched. (The exact reason for this bug is not fully understood yet.)
To check whether you are affected or not, issue:
( replace /dev/sda with the path of your own hard drive(s) )

$ sudo smartctl -a /dev/sda|grep "\(Load_Cycle_Count\|Power_On_Hours\)"
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 568
193 Load_Cycle_Count 0x0032 198 198 000 Old_age Always - 7926

Divide the value of the latter with the former. Under any circumstances you should not have more then 15 load cycles per hour.
Otherwise apply the following changes to avoid damaging your drive. Depending on model, disks usually give up between 100k and 600k load cycles .

  • In /etc/default/acpi-support increase SPINDOWN_TIME from 12 to at least 36. It will make your system more responsive when running on battery.
  • If you have a laptop, and if it works on your model (i.e. it does not crash), enable laptop-mode: in /etc/default/acpi-support set ENABLE_LAPTOP_MODE=true .
    I recommend the following configuration for laptop-mode in /etc/laptop-mode/laptop-mode.conf
#
# Enable laptop mode when on battery power.
#
ENABLE_LAPTOP_MODE_ON_BATTERY=1
(...)
#
# Should laptop mode tools control the hard drive power management settings?
#
CONTROL_HD_POWERMGMT=1
 
#
# Power management for HD (hdparm -B values)
#
BATT_HD_POWERMGMT=8
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=254
  • Create the executable file /etc/acpi/fix-load-cycles.sh
#! /bin/sh
#
# This script adjusts hard drive APM settings using hdparm. The hardware
# defaults (usually hdparm -B 128) cause excessive head load/unload cycles
# on many modern hard drives. We therefore set hdparm -B 254 while on AC
# power. On battery we set hdparm -B 8 so the power lasts longer.
 
DO_HDPARM=y
if [ -e /usr/sbin/laptop_mode ] ; then 
  LMT_CONTROL_HD_POWERMGMT=$(. /etc/laptop-mode/laptop-mode.conf && echo "$CONTROL_HD_POWERMGMT")
  if [ "$LMT_CONTROL_HD_POWERMGMT" != 0 ] ; then
    # Laptop mode controls hdparm -B settings, we don't.
    DO_HDPARM=n
  fi
fi
 
if [ $DO_HDPARM = y ] ; then
  AC_POWER=$( /usr/bin/on_ac_power; echo $? )
  for dev in /dev/sd? /dev/hd? ; do
    if [ -b $dev ] ; then
      if [ $AC_POWER -eq 1 ] ; then
        hdparm -B 8 $dev
      else
        hdparm -B 254 $dev
      fi
    fi
  done
fi
  • Create the appropriate symbolic links to it:

$ cd /etc/acpi
$ sudo ln -s ../fix-load-cycles.sh start.d/90-fix-load-cycles.sh
$ sudo ln -s ../fix-load-cycles.sh resume.d/90-fix-load-cycles.sh
$ sudo ln -s ../fix-load-cycles.sh ac.d/90-fix-load-cycles.sh
$ sudo ln -s ../fix-load-cycles.sh battery.d/90-fix-load-cycles.sh
$ sudo ln -s ../fix-load-cycles.sh suspend.d/90-fix-load-cycles.sh

If you are worried by this changes, that your computer might not be green anymore, please consider that an unused (but spinning) disk consumes approx. 1W of power. So even completely disabling spindown and power management would cost you _maximum_ 2-4 min. when running on battery. Also my disk and especially the data on it is more worth then the saving of 1W of power. Also remember that this power saving abilities only have an effect when neither you nor any program you run does not use the disk, which is rare.

I hope this issue will be resolved until the final release of Hardy. Debian already applied a very similar solution.

Column names not handled properly by Qt

Recently I worked on a Qt (4) application handling stuff in a (My) SQL database. Indeed I was pleased by the way Qt handles databases. Although there is a strange bug that took hours to get debugged.
The symptoms were: A widget with a QTableView with a QSqlTableModel as it's model recognized the table's column names, although it hasn't displayed any rows. Of course the table wasn't empty. Trying to insert rows resulted in:

ASSERT: "idx >= 0 && idx < s" in file ../../include/QtCore/../../src/corelib/tools/qvarlengtharray.h, line 80
Aborted (core dumped)

It took a while, but I figured out that column names containing a whitespace (`Phone Number`) or symbols like a dash (`E-mail`) caused the trouble. Renaming the columns solved the problem. Anyway, Qt is unable to handle column names properly.

Syndicate content