Sort of blog

You can eliminate a lot of bugs in your lua program easier (if you're writing it right way), if you do something like

local M = {
    __index =
        function ( t, v )
            error ( ('global variable %q accessed at %s'):format ( tostring ( v ), debug.traceback () ) )
        end,
    __newindex =
        function ( t, v, k )
            error ( ('global variable %q assigned %q at %s'):format ( tostring ( v ), tostring ( k ), debug.traceback () ) )
        end,
}
setmetatable ( _G, M )

This will terminate your program every time, non-existing global variable is accessed.

Posted 2011.07.28 14:45:10 +0300

Working on lua-undefined, I enabled debugging output in fellow libraries, and boom! It started to abort. Wtf? Some investigation revealed, that it is because g_log has been called from withing g_log, that glib considers very nasty and aborts immediately. Quick code investigation shown no sign of such a recursive calls. However, there were, but indirect. I installed log handlers to catch output of lua-lm and lua-glib. Now, lua-glib logs some message, and glib lua handler starts to act. It pushes it's args to pass them to fellow lua function, but this push causes lua gc run. During this gc run, some lm message or message node gots collected and logs this... right, with g_log, that kills the program.

I managed to make this not fatal by modifying glib fatal mask. But it still pollutes stdout (not stderr, that is catched into a log file) and confuses ncurses. And I do not know, why - maybe it's a bug in glib, because my handlers are installed with 'recursion' flag set, but yet they are not called, when such an event happens. Even default log handler is unable to intercept these messages :( In the end, I tired of this and just selectively disabled that destruction output.

Posted 2011.07.15 19:42:55 +0300

Ejabberd's xmpp muc component contains a bug, that causes undefined think, that it is not in the room (in other aspects it looks like works fine). The bug has been reported (EJAB-740) in 2008 :/ Probably, till then XEP-0045 has changed, if then it stated, that code 110 SHOULD be sent, now it is MUST. Put a note about that, let's hope, that it will be addressed soon.

Posted 2011.07.14 19:10:17 +0300

Found a bug in mount (util-linux package). When you remount a filesystem not in fstab, mount options get appended to option string without checking for option duplication, that causes unreadable mount output:

...
/home/mirror on /var/lib/schroot/mount/net-621f2f15-73d3-42d8-9970-908955880b1a/home/mirror type none (rw,bind,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600)
/home/isbear/net on /var/lib/schroot/mount/net-621f2f15-73d3-42d8-9970-908955880b1a/home/isbear type none (rw,bind,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600)
/srv/schroot/net on /var/lib/schroot/mount/net-8329b905-78ab-4c1f-ac67-430855f5cc47 type none (rw,bind,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600)
proc on /var/lib/schroot/mount/net-8329b905-78ab-4c1f-ac67-430855f5cc47/proc type proc (rw)
/dev on /var/lib/schroot/mount/net-8329b905-78ab-4c1f-ac67-430855f5cc47/dev type none (rw,bind)
/dev/pts on /var/lib/schroot/mount/net-8329b905-78ab-4c1f-ac67-430855f5cc47/dev/pts type none (rw,bind)
/run/shm on /run/shm type none (rw,bind)
/home/mirror on /var/lib/schroot/mount/net-8329b905-78ab-4c1f-ac67-430855f5cc47/home/mirror type none (rw,bind,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600)
/home/isbear/net on /var/lib/schroot/mount/net-8329b905-78ab-4c1f-ac67-430855f5cc47/home/isbear type none (rw,bind,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600)
/srv/schroot/net on /var/lib/schroot/mount/net-894651f2-91ec-49f8-886b-b32cc4495dd9 type none (rw,bind,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600,commit=600)
proc on /var/lib/schroot/mount/net-894651f2-91ec-49f8-886b-b32cc4495dd9/proc type proc (rw)
/dev on /var/lib/schroot/mount/net-894651f2-91ec-49f8-886b-b32cc4495dd9/dev type none (rw,bind)
/dev/pts on /var/lib/schroot/mount/net-894651f2-91ec-49f8-886b-b32cc4495dd9/dev/pts type none (rw,bind)
/run/shm on /run/shm type none (rw,bind)
...

I am using networking programs in schroot, thus so many bind-mounts not in fstab, and the machine is laptop, thus so much remounts (laptop-mode refuse to work with my hand-built kernel, but pm-utils still do remount filesystems, when I plug/unplug AC adapter).

This bug is reported to Debian BTS (Debian bug #401841) in 2006 :/, I submitted a patch, maybe now someone will do something about this...

Posted 2011.07.13 01:41:55 +0300