Wednesday, October 31, 2012

Inconsistency detected by ld.so: dl-open.c

Cleaned my Ubuntu laptop with Ubuntu Tweak and was left with a weird error when using Chrome and Firefox.  Chrome stopped loading pages while Firefox crashed completely.  Found out the problem only after starting Firefox from the console.  Error string reported by FFX:

Inconsistency detected by ld.so: dl-open.c: 667: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!

Used strace on Firefox and obtained the following output:


open("/lib/x86_64-linux-gnu/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/tls", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
open("/usr/lib/x86_64-linux-gnu/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/tls", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64-linux-gnu/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu", {st_mode=S_IFDIR|0755, st_size=49152, ...}) = 0
open("/lib/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/lib/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/tls", 0x7fffdd0b6c00)        = -1 ENOENT (No such file or directory)
open("/lib/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib/x86_64", 0x7fffdd0b6c00)     = -1 ENOENT (No such file or directory)
open("/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/usr/lib/tls/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/tls/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/tls", 0x7fffdd0b6c00)    = -1 ENOENT (No such file or directory)
open("/usr/lib/x86_64/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64", 0x7fffdd0b6c00) = -1 ENOENT (No such file or directory)
open("/usr/lib/libGL.so.1", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=73728, ...}) = 0
munmap(0x7fde2d69b000, 121572)          = 0
writev(2, [{"Inconsistency detected by ld.so:"..., 33}, {"dl-open.c", 9}, {": ", 2}, {"667", 3}, {": ", 2}, {"_dl_open", 8}, {": ", 2}, {"Assertion `", 11}, {"_dl_debug_initialize (0, args.ns"..., 61}, {"' failed!\n", 10}], 10Inconsistency detected by ld.so: dl-open.c: 667: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!) = 141

libGL.so.1 is there but it just doesn't get recognized by ld.  After digging the web for a few hours, finally found the solution.  Re-install some packages:

sudo apt-get install --reinstall libgl1-mesa-glx:amd64 libgl1-mesa-glx:i386 libgl1-mesa-dri:amd64 libgl1-mesa-dri:i386

Haven't had such crazy stuff in Ubuntu for a while :)



Sunday, September 23, 2012

Formatting currency in Drupal Commerce

A project I've been involved in uses Drupal Commerce (DC) to manage currency and products.  Here's how to format "normal" values to be DC friendly.  Reason for doing so?  DC stores amount fields as INTEGER.  For instance, an amount of USD99 is stored as 9900 in the table.

There are several functions which you need to make this happen.

commerce_currency_decimal_to_amount(300, commerce_default_currency());

Thursday, August 2, 2012

Checking if Java/Solaris is 32 or 64 bit

To check if Solaris is 32 or 64 bit, use the following command:

$ isainfo -kv
64-bit sparcv9 kernel modules


To check if JRE in Solaris is 32 or 64 bit, use the following command:

$ java -d64 -version
execve(): No such fie or directory
Failed to start a 64-bit JVM process from a 32-bit JVM

Well, that's a complain :)

Tuesday, March 13, 2012

Controlling Mouse Speed in Ubuntu when System Settings Doesn't Cut It (aka xinput)

My laptop comes with a Targus cordless mouse which moves too fast even when both Accelleration and Sensitivity in Pointer Speed settings is set to the lowest in Ubuntu. 

There's another method to control input speed via the xinput command.

To begin, execute "xinput list" to obtain the list of inputs available:

mike@myhost:~$ xinput list
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ SONiX Targus Soft-Touch Cordless Mouse      id=8    [slave  pointer  (2)]
⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
    ↳ Power Button                                id=6    [slave  keyboard (3)]
    ↳ Power Button                                id=7    [slave  keyboard (3)]
    ↳ Dell Dell USB Entry Keyboard                id=9    [slave  keyboard (3)]
    ↳ Dell WMI hotkeys                            id=10    [slave  keyboard (3)]

From the output above, it's quite obvious which input device we'll be working with (id=8 if you can't spot it).  Next, we'll move on to list down the device properties:

mike@myhost:~$ xinput list-props 8
Device 'SONiX Targus Soft-Touch Cordless Mouse':
        Device Enabled (143):   1
        Coordinate Transformation Matrix (145): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (260):     0
        Device Accel Constant Deceleration (261):       1.000000
        Device Accel Adaptive Deceleration (262):       1.000000
        Device Accel Velocity Scaling (263):    10.000000
        Evdev Axis Inversion (264):     0, 0
        Evdev Axes Swap (266):  0
        Axis Labels (267):      "Rel X" (153), "Rel Y" (154)
        Button Labels (268):    "Button Left" (146), "Button Middle" (147), "Button Right" (148), "Button Wheel Up" (149), "Button Wheel Down" (150), "Button Horiz Wheel Left" (151), "Button Horiz Wheel Right" (152), "Button Side" (524), "Button Extra" (525), "Button Unknown" (259), "Button Unknown" (259), "Button Unknown" (259), "Button Unknown" (259)
        Evdev Middle Button Emulation (269):    0
        Evdev Middle Button Timeout (270):      50
        Evdev Wheel Emulation (271):    0
        Evdev Wheel Emulation Axes (272):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (273):    10
        Evdev Wheel Emulation Timeout (274):    200
        Evdev Wheel Emulation Button (275):     4
        Evdev Drag Lock Buttons (276):  0

To properly "decelerate" the mouse pointer, we'll need to play around with 2 properties:
  • Device Accel Constant Deceleration (261)
  • Device Accel Adaptive Deceleration (262)
To update a property value, use the "--set-prop" option like below:
mike@myhost:~$ xinput --set-prop 8 261 4
Note the values used:
  • 8: device id
  • 261: property id
  • 4: value of the property to be set
Setting both property value to 4 works for me; YMMV.

Have fun tweaking your input :)



Tuesday, February 21, 2012

Using Python minidom module for XML generation

Creating an XML document in Python using the minidom module is quite straightforward.  For simplicity sake, I'll base the code on Hadoop's XML config file.

import sys
from xml.dom.minidom import Document

doc = Document()

configuration = doc.createElement("configuration")

xsl = doc.createProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"configuration.xsl\"")

doc.appendChild(xsl)

prop = doc.createElement("property")

# START LOOP HERE
name = doc.createElement("name")
name_text = doc.createTextNode("my name")
name.appendChild(name_text)

prop.appendChild(name)

value = doc.createElement("value")
value_text = doc.createTextNode("my value")
value.appendChild(value_text)

prop.appendChild(value)
# END LOOP HERE

configuration.appendChild(prop)

doc.appendChild(configuration)

print doc.toprettyxml()

The output is as follows:

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>
            my name
        </name>
        <value>
            my value
        </value>
    </property>
</configuration>