segfaults while compiling VLC on low memory system

5

I'm trying to compile VLC from this GitHub repo on my Allwinner device (ARM Cortex-A8 NEON with armhf kernel and about 380 MB of RAM) using instructions provided here.

I keep getting segfaults, so I created a swap partition like this:

 root@lianro:~/# dd if=/dev/zero of=/swap bs=1M count=1024
 root@linaro:~/# mkswap -c /swap
 root@linaro:~/# swapon /swap

It got better; instead of breaking randomly after about one minute it breaks randomly after a long time, last time it almost finished but I got a segfault on one of the last modules.

Swap doesn't seem to be used at all at any point during the compilation. I have plenty of disk space free.

What can be the problem?

NotGaeL

Posted 2013-07-27T16:00:20.390

Reputation: 375

Can you post the lines leading up to the segmentation fault? Does it always segfault at the same location? Does echo 2 > /proc/cpu/alignment help? (If it does you have an alignment bug. X86 architecture allows this albeit with a big performance impact. Other architectures often require you do do it right. Tools/programs which get ported often run into these problems. (Though without the error I am just guessing).

– Hennes – 2013-07-27T16:56:09.267

When you say that swap isn't being used, how do you know? Anything in dmesg relating to oom-killer? – Flup – 2013-07-27T17:12:50.180

I just ran top in another terminal while compiling. Physical memory is almost full but swap is empty during compilation. I finally managed to compile it all just by trying a few times in a row. The whole process took me almost 4 hours, good thing it doesn't need to recompile already compiled modules! – NotGaeL – 2013-07-27T17:58:13.187

@Hennes the segfaults are random, the lines leading to it are all cc somemodule and the compiler displays a message saying it's a segfault and it cannot trace the problem and it must be SO related. echo 2 > /proc/cpu/alignment didn't help – NotGaeL – 2013-07-27T18:03:25.587

@Flup I forgot: dmesg|grep oom shows nothing. – NotGaeL – 2013-07-27T18:12:22.650

1You might find it easier to set up a cross compile configuration on your main machine. Doing this using something like chroot/schroot might make it significantly simpler. I know that there are instructions on setting up Ubuntu for cross compiling onto the Raspberry Pi (another ARM platform) so it should be possible. – KayEss – 2013-08-01T03:07:45.777

If you're compiling with Android as the target OS, there should be binaries available for your device already, also. – Suchipi – 2013-08-04T16:49:56.500

Answers

1

If compilation of a particular module requires more RAM than you physically have available, swap will not help, because the program will attempt to allocate and use significantly more RAM than you have in the system and swap cannot make up for that. Linux can't swap out memory that is actively in use.

You might try manually changing the CFLAGS or the Makefile rule for compilation for the particular module that's crashing to not perform optimization (-O0) or to use a lower level of optimization (-O1 or -Os for example). This will use significantly less memory during compilation, and while it isn't ideal, it may allow the compilation to succeed. Media players tend to use expensive optimizations that require lots of RAM, both at compile-time and at runtime.

Jody Lee Bruchon

Posted 2013-07-27T16:00:20.390

Reputation: 178