Motion-Project/motion

Compiling on Raspberry Pi3: Error in `gcc': double free or corruption

Closed this issue · 17 comments

Hi,

When I try to configure/compile Motion on Raspberry Pi v3, I get errors:

pi@raspberrypi:~/motion $ ./configure
...
Detected CPU: ARMv7 Processor rev 4 (v7l)
*** Error in `gcc': double free or corruption (top): 0x014735e8 ***
./configure: line 6778: 8012 Aborted ( $COMPILER $CPU_OPTIONS -o $TMPO $TMPC ) 2>&1
CPU optimization: -march=native -mtune=native

...

pi@raspberrypi:~/motion $ make
...
Welcome to the setup procedure for Motion, the motion detection daemon! If you get
error messages during this procedure, please report them to the mailing list. The
Motion Guide contains all information you should need to get Motion up and running.

Version: Unofficial-Git-2caced3
Platform: Linux (if this is incorrect, please read README.FreeBSD)

Generating dependencies, please wait...
*** Error in `gcc': double free or corruption (top): 0x010374f0 ***
Aborted
Makefile:121: recipe for target '.depend' failed
make: *** [.depend] Error 134
...

Raspbian ver:
pi@raspberrypi:~/motion $ uname -a
Linux raspberrypi 4.1.19-v7+ #858 SMP Tue Mar 15 15:56:00 GMT 2016 armv7l GNU/Linux

GCC ver:
gcc version 4.9.2 (Raspbian 4.9.2-10)

There is no problems when compiling motion on RasPi v1 or v2 platform.

Can confirm this error - exactly the same output when compiling on Raspberry Pi 3 running the Kali distribution. From configure:

Detected CPU: ARMv7 Processor rev 4 (v7l)
*** Error in `gcc': double free or corruption (top): 0x00a4a528 ***
./configure: line 6790: 17840 Aborted ( $COMPILER $CPU_OPTIONS -o $TMPO $TMPC ) 2>&1
Linux version:
root@kali:~# uname -a
Linux kali 4.1.19-v7 #1 SMP Tue Mar 15 15:10:00 CDT 2016 armv7l GNU/Linux

gcc -v reports (truncated):
gcc version 5.3.1 20160409 (Debian 5.3.1-14)
and relevant architecture flags:
--with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf

I suspect it might be related to the upgraded ARM CPU, but I'm not an ARM expert and haven't done any digging yet. Cheers!

I do not own one of these so resolving it on my end is going to be difficult. If I am reading the message correctly, it appears that the first error seems to be with the configure. I assume that you are using the command autoreconf -fiv as different options are checked with the configure. You can possibly try the --without-optimizecpu configure option. After that I think you may have to start looking at what line in the configure script is failing and then going back to the configure.ac file to determine the root cause.

I have compiled motion for many different ARM platforms and never had any errors. Those include: sunxi (MK802, BananPi), rk3066 (MK808), rk3188 (radxa, MK802IV), ODROID U2 and ODROID C1. Just used ./configure without any extra params - and that does job well

Seems to be a gcc ARM auto detection bug.
Compiled without any errors on RPi3 with this forced parameters:
-mcpu=cortex-a53 -mfpu=neon-vfpv4

Thank you very much for the follow up on the resolution. There are CPU detection options that are in the configure.ac that may permit the detection of the CPU and adding these. I have not however used/revised them while working on this project. In order to add this, we'd need to know what is unique with the RPI3 in the /proc/cpuinfo. For reference, the detection section is around line 890.

@Serverov Can you please post the string you used to compile motion with those parameters? I'm not entirely sure how to use them with configure.

@retrostrobe
In Makefile, CFLAGS variable:
replace "-march=native -mtune=native" to "-mcpu=cortex-a53 -mfpu=neon-vfpv4"

Can either of you report the exact output of the following commands so that we can see about getting the pi3 recognized in the configure and these options added?

cat /proc/cpuinfo | grep "cpu family" | head -n1
cat /proc/cpuinfo | grep model[[^\ ]] | head -n1
cat /proc/cpuinfo | grep "model name" | head -n1
cat /proc/cpuinfo | grep "flags" | head -n1
cat /proc/cpuinfo | grep "vendor_id" | head -n1
uname -p
uname -m

Thanks

@Mr-Dave here it is...
rpi: $ cat /proc/cpuinfo | grep "cpu family" | head -n1
rpi: $ cat /proc/cpuinfo | grep model[[^\ ]] | head -n1
rpi: $ cat /proc/cpuinfo | grep "model name" | head -n1
model name : ARMv7 Processor rev 4 (v7l)
rpi: $ cat /proc/cpuinfo | grep "flags" | head -n1
rpi: $ cat /proc/cpuinfo | grep "vendor_id" | head -n1
rpi: $ uname -p
unknown
rpi: $ uname -m
armv7l

To follow up on this issue. What I observed is that the parameters above do not seem to uniquely identify the PI3. The PI3 is a ARMv8 from the specs that I found. This seems to be a common observation of the PI3 owners. The configure script needs to be able to uniquely identify the PI3 so that it can add the extra compiler options. If owners of a PI3 can find and post something unique that we can test for, we can see about getting the extra compiler options added.

jogu commented

I've put two commits on to my master that I think should fix it; they're linked above - not sure if github emailed everyone - if they did apologies that it took be 4 attempts before I managed to push the commits with the right commit message included!)

@Serverov , @techabuse , @retrostrobe , @blackdot Can any of you pull from the jogu master branch and validate that it is working for you and report back here? I would like to get confirmation before it goes into the project master. Thanks.

I can confirm that I've successfully compiled motion using @jogu's fork. As a reference, I also tried compiling @Mr-Dave's latest fork, which failed. Thank you guys!

Detected CPU: Raspberry Pi 3
CPU optimization: -mcpu=cortex-a53 -mfpu=neon-fp-armv8

jogu commented

Thanks @retrostrobe - it is very much appreciated when people can help us with testing!

ab1jx commented

Thank you, fixed a similar problem I was having in something else by mostly using your fix.

@retrostrobe
In Makefile, CFLAGS variable:
replace "-march=native -mtune=native" to "-mcpu=cortex-a53 -mfpu=neon-vfpv4"

This works for me. Thanks.

ab1jx commented

Big can of worms. I've looked it up but I can never remember. Native is usually trouble. I do a search like https://www.google.com/search?q=march+mcpu+mfpu+mtune+pi3+site%3Araspberrypi.org&oq=march+mcpu+mfpu+mtune+pi3+site%3Araspberrypi.org&gs_l=psy-ab.12...7796.7796.0.12413.1.1.0.0.0.0.520.520.5-1.1.0....0...1.1.64.psy-ab..0.0.0.81qsvJTCLlk or look at the hardware specs. There's probably a slight gain to be had by getting exactly the right thing but nothing at all is better than the wrong thing.

On a Pi at least do: cat /proc/cpuinfo and you should get something like:
processor : 0
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 76.80
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
(x 4 for each core)

The a53 didn't look right but it is https://www.raspberrypi.org/magpi/raspberry-pi-3-specs-benchmarks/