public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [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))
@ 2015-04-26 16:14 hdusel at macbay dot de
  2015-04-27 11:43 ` [Bug target/65895] " gjl at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hdusel at macbay dot de @ 2015-04-26 16:14 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/65895] 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))
  2015-04-26 16:14 [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)) hdusel at macbay dot de
@ 2015-04-27 11:43 ` 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
  2 siblings, 0 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2015-04-27 11:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Author: gjl
Date: Mon Apr 27 11:43:20 2015
New Revision: 222459

URL: https://gcc.gnu.org/viewcvs?rev=222459&root=gcc&view=rev
Log:
        PR target/65296
        PR target/65895
        * config/avr/gen-avr-mmcu-specs.c (print_mcu): Close file.
        Add hint how to use own spec file.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/gen-avr-mmcu-specs.c


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/65895] 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))
  2015-04-26 16:14 [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)) hdusel at macbay dot de
  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
  2 siblings, 0 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2015-04-27 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Author: gjl
Date: Mon Apr 27 11:49:42 2015
New Revision: 222460

URL: https://gcc.gnu.org/viewcvs?rev=222460&root=gcc&view=rev
Log:
        Backport from 2015-04-27 trunk r222459.
        PR target/65296
        PR target/65895
        * config/avr/gen-avr-mmcu-specs.c (print_mcu): Close file.
        Add hint how to use own spec file.


Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/config/avr/gen-avr-mmcu-specs.c


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug target/65895] 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))
  2015-04-26 16:14 [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)) hdusel at macbay dot de
  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
  2 siblings, 0 replies; 4+ messages in thread
From: gjl at gcc dot gnu.org @ 2015-04-27 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |build
                 CC|                            |gjl at gcc dot gnu.org
             Blocks|                            |65296
           Assignee|unassigned at gcc dot gnu.org      |gjl at gcc dot gnu.org
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.2
      Known to fail|                            |5.1.0
           Severity|minor                       |normal

--- Comment #3 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
Fixed in 5.2.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65296
[Bug 65296] [avr] fix various issues with specs file generation


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-27 11:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-26 16:14 [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)) hdusel at macbay dot de
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

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).