public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hdusel at macbay dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65895] New: Segfault building cross GCC 5.1.0 for Target AVR on Mac OSX 10.10.3 (using Apple LLVM version 6.1.0 (clang-602.0.49))
Date: Sun, 26 Apr 2015 16:14:00 -0000	[thread overview]
Message-ID: <bug-65895-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65895

            Bug ID: 65895
           Summary: Segfault building cross GCC 5.1.0 for Target AVR on
                    Mac OSX 10.10.3 (using Apple LLVM version 6.1.0
                    (clang-602.0.49))
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hdusel at macbay dot de
  Target Milestone: ---
              Host: Mac OS X 10.10.3
            Target: AVR
             Build: Mac OS X 10.10.3

Using Apple LLVM version 6.1.0 (clang-602.0.49) to build released version 5.1.0
leads into a segfault:

-----------------------------------
g++ 
/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/config/avr/gen-avr-mmcu-specs.c
-o gen-avr-mmcu-specs -I. -I.
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/.
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/../include
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/../libcpp/include
-I/tmp/build_cross_gcc/gcc-5.1.0_build_avr/./gmp
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gmp
-I/tmp/build_cross_gcc/gcc-5.1.0_build_avr/./mpfr
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/mpfr
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/mpc/src 
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/../libdecnumber
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/../libdecnumber/dpd
-I../libdecnumber
-I/tmp/build_cross_gcc/gcc-5.1.0_arch/gcc-5.1.0/gcc/../libbacktrace 
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is
deprecated
rm -rf device-specs
mkdir device-specs && cd device-specs &&  ../gen-avr-mmcu-specs
/bin/sh: line 1: 62583 Segmentation fault: 11  ../gen-avr-mmcu-specs
make[2]: *** [s-device-specs] Error 139
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2
-----------------------------------

I finally found the reason for the segfault! It is located within
gcc/config/avr/gen-avr-mmcu-specs.c

In the function print_mcu(const avr_mcu_t *mcu) For every spec file that is
about to be generated by gen-avr-mmcu-specs a file handle is created but this
handle is __not__ closed when the function leaves. 

On OS X 10.10.3 (haven't tried other versions of Mac OS X) the total number of
opened files per process is apparently lower than the files processed by this
tool. Hence after this count of opened handles has exceeded the OS will return
NULL for any further attempt to open a new file.

-> So accessing a NULL Pointer for the file handler leads to the segfault.

The solution is simple: Simply call fclose(f) when the function leaves. In
addition it would be fine if a returning file handle of NULL will be checked
and acknowledged by the tool by an appropriate error message either. At least
the code should not attempt to proceed with a NULL for the file handle though.

I verified this proposed changes on my system -> build proceeds.


             reply	other threads:[~2015-04-26 16:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-26 16:14 hdusel at macbay dot de [this message]
2015-04-27 11:43 ` [Bug target/65895] " gjl at gcc dot gnu.org
2015-04-27 11:50 ` gjl at gcc dot gnu.org
2015-04-27 11:53 ` gjl at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65895-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).