rnd's website logomidnight commander subshell bug

After updating Alpine Linux on my VPS to version 3.14, I noticed that Midnight Commander (mc) crashed with a segmentation fault around 90% of the time, and at other times it ran, but refused to accept any input.

At first, I thought that it had to do with the OS update itself and something was wrong with the version of mc or some other package built in Alpine, so I tried building mc with ncurses instead of slang as it was before, but to no effect. To make matters worse, the bug disappeared when I tried to trace it in strace or valgrind.

Eventually, I figured out that the best way to find out the cause is to just build the mc package with the debugging symbols. To do that in Alpine, you need to modify the APKBUILD file describing the package by adding a $pkgname-dbg subpackage and setting a !strip option, so that abuild doesn't remove the debugging symbols and knows where to put them.

As a result, I was able to trace the bug to its source: a g_string_free operation that is called even though the pointer to the string is empty. As it turned out, it's a known issue listed as mc bug #4213.

Until the bug is fixed, the best option is to always run mc with subshells disabled. In my case, I just added the following string to my ~/.profile:

alias mc='mc -u'
Follow me on Mastodon This page made with Vim Best viewed in Firefox jan li lukin e lipu ni lon tenpo mute Trans Rights Now!