Debug memory errors with valgrind

For debugging memory errors valgrind is very useful tool.

broken program would show

$ ./program
*** glibc detected *** double free or corruption (out): 0x08138a80 ***

valgrind shows where the problem occurs

$ valgrind ./program</div>
<div>==31784== Invalid free() / delete / delete[]
==31784==    at 0x1B90579D: free (vg_replace_malloc.c:152)
==31784==    by 0x1BB2E6CD: xfree (xmalloc.c:200)
==31784==    by 0x1BB25095: _xFreePtr (mem.c:613)

For debugging with valgrind I use following configuration:

~/.valgrindrc file


To disable glibc memory errors detection you need to set MALLOC_CHECK_ environment variable to 0 (note the ending underscore).

export MALLOC_CHECK_=0
Posted in Programming | Tagged , , | Leave a comment

WindowMaker DockApp fix

WindowMaker DockApp does not show, or show in regular window

Normally DockApps should be displayed in special mode, so they can be docked in one of the screen corners. They also does not have titlebar, and does not require to be placed manually (if this is set up in Window Maker).

Some old DockApp applications are somehow incompatible with recent WindowMaker (tested on 0.91+), and either does not display at all, or display in regular “window”.

I didn’t see confirmation of that behavior, so maybe this is only my issue (but on a few machines) but solution I found is to fix the source code bye  changing one line of it. Search for res_class string in the source and change right side of the expression to the "DockApp". Recompile.

Old code

something.res_class = "anything";

New code

something.res_class = "DockApp";

Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.
Posted in Linux | Tagged , | 1 Comment

Playing DVD movie stored in an image on a disk

mplayer dvd:// -dvd-device /tmp/movie-image.iso
Posted in Linux | Tagged , , | 1 Comment

Forward email as an attachment in pine

By default pine attaches forwarded messages inline.
Here is trick to forward email as an attachment.
It is sometimes important that you preserve original headers when forwarding email. Eg., if you want to report spam.
Forwarding as attachment do preserve email headers, attachment inline does not.


  1. Open (or put cursor on) message you want to forward
  2. Enter Full Headers mode¹ (press h)
  3. Forward the mail (press f)
  4. Accept ‘Forward message as an attachment?’ (press y)

Tested on pine 4.62. Is there any simple method? What displaying full headers has to do?

¹To be able to enter Full Headers mode, you may need to enable it in configuration:
On main screen enter Setup (press s), Config (c), and check (x) enable-full-header-cmd in Advanced Command Preferences. Exit and save (e, y).

Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.

Posted in Linux | Tagged , | Leave a comment

NFS: Permission denied

Not sure since what kernel, but you need to mount nfsd virtual file system on server. Otherwise you will get:

mount: failed, reason given by server: Permission denied

To resolve it type:

on server root console

mount -t nfsd none /proc/fs/nfsd

You can safely make that permanent (automount on boot):

edit /etc/fstab and add following line

none                    /proc/fs/nfsd   nfsd     defaults 0 0

It took me a few hours to resolve this issue… There are so many questions about above Permission denied message over the Internet, but I didn’t find single answer with this hint…

More troubleshooting

  • Make sure you have NFS compiled in kernel.
  • Check the firewall settings and SELinux settings. Eventually disable both for test.
  • On Fedora Core 5 I found out the I’m getting:
    _sqlite.OperationalError: database is locked

    Until I start NFS locking service on both server & client:

    service nfslock start

More resources: sharing between SELinux Fedora Core and non-SELinux system

Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.

Posted in Linux | Tagged , | 1 Comment

Quick NFS setup

Sometimes you need to setup “on demand” connection to access resources on other machine.

I found it useful sharing yum cache (1GB+ of already downloaded updates) with the laptop that needs to be updated as well.
Normally laptop update would re-download most of the files. Mounting /var/cache/yum in read-write mode from my desktop computer on laptop’s /var/cache/yum saves me a few hours.

  1. Make sure that your /etc/hosts.allow includes your LAN in allow section. Important: following setup is security risk. Don’t use it in an untrusted environment.

    rpcbind : : allow
    rpcbind : ALL : deny

  2. Export filesystem on server. Assume that your LAN is in range. Actual values can be found in ifconfig command output (addr/mask).
    on server root console

    service portmap start
    service nfs start
    exportfs -o rw,no_root_squash

  3. Mount the share on the client. Assume that server’s IP is
    on client root console

    service portmap start
    mount /var/cache/yum -o nfsvers=2,rw

  4. To make such setup permanent, add portmap and nfs to services that startup at boot, edit /etc/exports on server and /etc/fstab on client. Remember that you are giving write access (also as root what is extremely dangerous) to anybody that can connect to your LAN (

See also: NFS troubleshooting

Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.

Posted in Linux | Tagged , | Leave a comment

IOGear GWU513 usb wireless adapter on Linux

IOGear 802.11g WiFi card happens in two flavors. Earlier version (I’ll call it v1) has ISL3880 chip and is fully¹ supported by recent kernels ( at least). Later version (v2) has GW3887 chip and would (will) be supported by the vanilla kernel¹, but its id is not added to the driver configuration.

To check if you have older or newer card you can use lsusb command. 124A:4023 is v1, while 124a:4025 is newer v2.

¹ Kernel driver needs an external firmware called SoftMAC to run. It is available from Prism Firmwares site. More information can be also obtained at (except that as of now neither mention newer GWU 513 card at all).

So to make v2 GWU513 card work, you need to:

  1. patch the kernel with add a 124a:4025 id patch and recompile it
  2. download the “Second generation device” firmware (for v1 it would be “First generation device”,
  3. put it in appropriate place at appropriate name in the system (on mine Fedora 8 it is /lib/firmware/isl3887usb_bare)
  4. load/reload p54usb kernel module (i.e. rmmod p54usb; modprobe p54usb)
  5. iwconfig should show the new card

Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.

Posted in Linux | Tagged , , , | Leave a comment

Very slow or dying Internet connection to some hosts

I you have very slow (or quickly dying) connection to selected hosts and they work normally from other machines/systems you may be experiencing broken TCP window scaling on a host that is on the route between you and the target machine.

The slow connection often gets noticed after recent system/kernel upgrade, or after adding more RAM to the system.

Problem is that Linux kernel’s window scaling parameters depends on the amount of system RAM, and other factors, so while old system could keep the TCP window size small, new may grow it more (i.e. for overseas connection), and broken boxes that mishandle window scaling parameter, effectively blocks the connection with large TCP window size. Notice that window scaling parameter changes during the TCP transfer, thus connection can start well, and got broken after some time.

To check if your connection is affected by this problem you can temporarily disable window scaling with:

as root

echo 0 > /proc/sys/net/ipv4/tcp_window_scaling

Another proposed workaround is to limit maximal window size with:

as root

echo 4096 16384 131072 > /proc/sys/net/ipv4/tcp_wmem
echo 4096 87380 174760 > /proc/sys/net/ipv4/tcp_rmem

It is also possible to make these limitations only for a selected broken route (not to limit connection performance for entry system):

There are black box devices out there, routers and firewalls and whatnot, that simply cannot grok the TCP window scaling option correctly.

People should and do bark at the site running the device causing the problems, but in the mean time folks do want a way to deal with the problem. We don’t want them to turn off window scaling completely as that hurts performance of connections that would run just fine with window scaling enabled.

So give a way to do this on a per-route basis by limiting the window scaling by the per-connection window clamp. Stephen’s changelog message explains how to do this using a route metric.

as root

ip route add via window 65535

You can make any of these workarounds permanent, by adding those lines to your /etc/rc.local file.


Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.

Posted in Linux | Tagged , , | Leave a comment

ZIP unsupported compression method 99

Some password protected ZIP files, usually created with a recent WinZip (9.0 or newer), are encrypted using new method, the AES encryption.

Older utilities like unzip on Linux, old WinZip, or pkunzip does not know how to handle that, and usually just abort operation complaining that they does not support compression method 99.

To extract those ZIP files one can use:

  • recent WinZip (Windows only, €30, free trial)
  • 7z tool (Windows, Linux, Mac OS X & others, free, open source – LGPL)

The 7z can be obtained from the 7z home site, but for Linux should be easily available from the system repository.

on Fedora you can install it with:

yum install p7zip p7zip-plugins

Command line syntax for extracting the archive is:

7z x

Post Scriptum: this is an import of information that I wrote a while ago. Things might have changed since then.

Posted in Linux | Tagged , | 11 Comments

Linux – Programming – Technology: blog introduction

For a few years I used to maintain random set of pages with some thoughts or tips on various Linux and programming related topics. A few of these pages got some attention over the time (Linux on Sony Vaio FX240 – when Linux on laptop was not that obvious, Skype on Linux – when Skype used to have annoying problems with sound system, OpenOffice macro for Polish users seeking number-to-text macro), but all together it has never been a crowded or regularly updated place. This is probably not going to change.

As of now I have decided that something more advanced than random HTML pages will have a few advantages.

First of all there will be RSS for free, so there is possibility to get notified if I add something time to time.

The next important factor are comments. Till now all communication was done by direct email to me and I eventually updated the pages afterwards. But emails could be a limiting factor. At least for me it is easier (also mentally) to fill a comment form than to write an email.

Then the workload for adding new things is much less with that setup, so there is a bigger chance that I will add something here more often.

And lastly, WordPress is well know, so the navigation should be a lot easier and more consistent then it used to be.

Posted in Meta | Leave a comment