Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in `g++': double free or corruption #27

Closed
ikem-krueger opened this issue Jun 13, 2016 · 19 comments

Comments

@ikem-krueger
Copy link

@ikem-krueger ikem-krueger commented Jun 13, 2016

I owe a Raspberry Pi 3.

After extracting I run make.

When I run "make" I got the following error:

mkdir -p /home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/build
rm -f /home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/build/vis
g++ -std=c++14 -O3 -march=native -ffast-math -fno-omit-frame-pointer -D__extern_always_inline=inline -D_LINUX -DNCURSESW -fno-omit-frame-pointer -DNCURSESW -I/usr/local/include -I/home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/include -I/home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/src -c src/vis.cpp -o /home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/build/vis.o
*** Error in `g++': double free or corruption (top): 0x0083acc0 ***
Makefile:214: recipe for target '/home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/build/vis.o' failed
make: *** [/home/ikem/Downloads/cli-visualizer_1.1/cli-visualizer-1.1/build/vis.o] Aborted

According to this site, gcc has trouble to detect the right architecture.

I fixed it by editing the "Makefile" and changing the lines:

CXX_FLAGS += -march=native
PERF_TEST_CXX_FLAGS += -march=native

To this lines:

CXX_FLAGS += -march=armv6
PERF_TEST_CXX_FLAGS += -march=armv6

And it compiled without an error.

@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Jun 13, 2016

Thanks! I've pushed a fix so that on Raspberry Pi 3's the install script will force armv6 arch.

@dpayne dpayne closed this Jun 13, 2016
@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 12, 2016

Commenting to state that this bug still persists, just had it on jessie on an rpi3, fixed by following the above notes of changing to armv6.

@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Oct 12, 2016

@icecube45 would mind running uname -m on your rpi3? The fix I pushed out previously used uname to check the architecture and my guess is that it is slightly different on your rpi3. Here is the check https://github.com/dpayne/cli-visualizer/blob/master/install.sh#L5.

@dpayne dpayne reopened this Oct 12, 2016
@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 12, 2016

I'm getting armv7l as the output

@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Oct 13, 2016

Would you mind building the latest install.sh script. I added a line for arm7 https://github.com/dpayne/cli-visualizer/blob/master/install.sh#L6

@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 13, 2016

No luck,

g++ -std=c++14 -O3 -march=native -ffast-math -fno-omit-frame-pointer -D__extern_always_inline=inline -D_LINUX -DNCURSESW  -fno-omit-frame-pointer -DNCURSESW -I/usr/local/include -I/home/pi/cli-visualizer/include -I/home/pi/cli-visualizer/src -c src/vis.cpp -o /home/pi/cli-visualizer/build/vis.o
*** Error in `g++': double free or corruption (top): 0x012e2308 ***
Makefile:218: recipe for target '/home/pi/cli-visualizer/build/vis.o' failed
make: *** [/home/pi/cli-visualizer/build/vis.o] Aborted
cp /home/pi/cli-visualizer/build/vis /bin/
cp: cannot stat ‘/home/pi/cli-visualizer/build/vis’: No such file or directory
Makefile:210: recipe for target 'install' failed
make: *** [install] Error 1

@DuckThom

This comment has been minimized.

Copy link
Contributor

@DuckThom DuckThom commented Oct 13, 2016

I don't think the if statement is matching armv7l so it's not doing export "VIS_COMPILER_ARCH"="armv7".

Tested with:

$ ARCH="armv7l"

$ echo $ARCH
armv7l

# The current if statement
$ if [[ $ARCH == "arm7"* ]]; then echo "Match"; else; echo "No match"; fi
No match

# Working if statement
$ if [[ $ARCH == "armv7"* ]]; then echo "Match"; else; echo "No match"; fi
Match
@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Oct 13, 2016

Thanks for finding the fix! The script is updated now.

@DuckThom

This comment has been minimized.

Copy link
Contributor

@DuckThom DuckThom commented Oct 13, 2016

I think the other if statement might also not work as on my Pi 1 model B uname -m returns armv6l

@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 13, 2016

I'll confirm the pi3 works this afternoon - being as the script finds a match now it's likely, but best to confirm.
@DuckThom @dpayne yea, the "armv6"* needs to be implemented as well

@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 13, 2016

Haha, well, seems the initial issue is solved, we've got a new one now - not sure if we want to split it into its own issue being as it seems related.

mkdir -p /home/pi/cli-visualizer/build
rm -f /home/pi/cli-visualizer/build/vis
g++ -std=c++14 -O3 -march=armv7 -ffast-math -fno-omit-frame-pointer -D__extern_always_inline=inline -D_LINUX -DNCURSESW  -fno-omit-frame-pointer -DNCURSESW -I/usr/local/include -I/home/pi/cli-visualizer/include -I/home/pi/cli-visualizer/src -c src/vis.cpp -o /home/pi/cli-visualizer/build/vis.o
src/vis.cpp:1:0: error: target CPU does not support ARM mode
 /*
 ^
Makefile:218: recipe for target '/home/pi/cli-visualizer/build/vis.o' failed
make: *** [/home/pi/cli-visualizer/build/vis.o] Error 1
cp /home/pi/cli-visualizer/build/vis /bin/
cp: cannot stat ‘/home/pi/cli-visualizer/build/vis’: No such file or directory
Makefile:210: recipe for target 'install' failed
make: *** [install] Error 1
@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Oct 13, 2016

I set it to arm6 even though it's says armv7. Could you pull and try again.

@DuckThom

This comment has been minimized.

Copy link
Contributor

@DuckThom DuckThom commented Oct 13, 2016

I noticed on wikipedia that the Pi 3 Model B has an armv8 processor (which would be weird if your uname -m returns armv7l) but the following is quoted from the Pi's wikipedia page:

The Raspberry Pi 2 uses a Broadcom BCM2836 SoC with a 900 MHz 32-bit quad-core ARM Cortex-A7 processor (as do many current smartphones), with 256 KB shared L2 cache.

The Raspberry Pi 3 uses a Broadcom BCM2837 SoC with a 1.2 GHz 64-bit quad-core ARM Cortex-A53 processor, with 512 KB shared L2 cache.

The ARM Cortex-53 is an armv8 processor.
What is the output from cat /proc/cpuinfo @icecube45 ?

@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Oct 13, 2016

I think at least part of the problem is that gcc isn't recognizing it as the correct architecture.

@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 13, 2016

@DuckThom

processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
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

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
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

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
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

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
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

Hardware        : BCM2709
Revision        : a22082
Serial          : 0000000096ffc4f1

@dpayne commit 9b52d41 did make it compile correctly - not sure if forcing armv6 is the right approach, but it does appear to work.

@DuckThom

This comment has been minimized.

Copy link
Contributor

@DuckThom DuckThom commented Oct 13, 2016

I see, i was just curious because the error error: target CPU does not support ARM mode made me wonder whether you have an armv8 or armv7.

@DuckThom

This comment has been minimized.

Copy link
Contributor

@DuckThom DuckThom commented Oct 13, 2016

After some more digging around it seems that the Pi 3's processor is not an armv7 but an armv8.
The fact that it's displaying 4 cores in you /proc/cpuinfo confirms that it's actually a Cortex A53 (armv8).
More info here. https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=140572.

What is pretty clear with cpuinfo is that it identifies the Raspberry Pi 3 processor as an ARMv7, this appears to be a failure in the software for now but this may change with a kernel/firmware update to ARMv8.

(Source: https://www.element14.com/community/community/raspberry-pi/blog/2016/02/29/the-most-comprehensive-raspberry-pi-comparison-benchmark-ever)

The actual architecture will be difficult to detect with a simple if statement in that case. 😛

@icecube45

This comment has been minimized.

Copy link

@icecube45 icecube45 commented Oct 13, 2016

@DuckThom interesting, luckily it seems that the armv6 forcing has fixed the issue for now.. That might change at a later date.

@dpayne

This comment has been minimized.

Copy link
Owner

@dpayne dpayne commented Oct 13, 2016

For now I am just going to close this. If there's a Raspberry Pi software update I might need to change it again, but for now it seems to at least compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.