https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70132
Bug ID: 70132 Summary: ARM -mcpu=native can cause a double free abort. Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: dariushardy1 at gmail dot com Target Milestone: --- When attempting to use cpu autodetection (either -mcpu=native or -march=native) on ARM where the cpu isn't known by the detection routine e.g. Cortex-A53 in aarch32 mode, the detection function attempts to fclose() a file twice. gcc/config/arm/driver-arm.c 131 fclose (f); 132 133 if (val == NULL) 134 goto not_found; 135 136 return concat ("-m", argv[0], "=", val, NULL); 137 138 not_found: 139 { 140 unsigned int i; 141 unsigned int opt; 142 const char *search[] = {NULL, "arch"}; 143 144 if (f) 145 fclose (f); When the cpu identifier isn't know val=NULL when it enters this part and the file f ("/proc/cpuinfo") will be closed on line 131, and then again at 145 causing an abort. Setting f = NULL after the first fclose() should prevent it but it isn't done. rpi3 is a Cortex-A53 running in aarch32 mode. Whilst the A53 is known and gcc will compile for it, the autodetect code doesn't have it listed. pi@rpi3:~ $ gcc -mcpu=native *** Error in `gcc': double free or corruption (top): 0x00f5abd0 *** Aborted Noticed in 4.9.2, but the code for 5.3.0 appears to still have this. pi@rpi3:~ $ gcc --version gcc (Raspbian 4.9.2-10) 4.9.2