public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66370] New: compiler crashes when compiling a function with a huge number of arguments
@ 2015-06-01 21:58 jcarbaut at hotmail dot fr
  2015-06-02  9:03 ` [Bug rtl-optimization/66370] " rguenth at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: jcarbaut at hotmail dot fr @ 2015-06-01 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66370
           Summary: compiler crashes when compiling a function with a huge
                    number of arguments
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jcarbaut at hotmail dot fr
  Target Milestone: ---

This happens with the mingw-w64 distribution on Windows 7, with gcc-4.9.2, 64
bits.

I make a "fake" function with many arguments, with the following python script.
The function computes the sum of its arguments, which are all of type long. The
result is also of type long.
The variable "n" in the python script is the number of arguments. The output is
sent to a C file, which is then compiled.

n = 10907
for i in [n]:
    print("long f(")
    s = "return"
    for j in range(1, 1 + i):
        if j == i:
            print("    long a%x) {" % j)
            s += " a%x;" % j
            print("%s\n}" % s)
        else:
            print("    long a%x," % j)
            s += " a%x + \n" % j

With "gcc -c" (that is, no optimization), the compilation runs without a
problem for n<28040 and crashes for n=28040 or larger.

With "gcc -c -O1" or any higher level of optimization, the compilation runs for
n<10907 and crashes for n=10907 or larger.

While this function is utterly useless, it may show some bug in the compiler,
since, I guess, it's not supposed to crash on weird input. It's a kind, a very
trivial kind, of stress test for the compiler.


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

* [Bug rtl-optimization/66370] compiler crashes when compiling a function with a huge number of arguments
  2015-06-01 21:58 [Bug c/66370] New: compiler crashes when compiling a function with a huge number of arguments jcarbaut at hotmail dot fr
@ 2015-06-02  9:03 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-02  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |compile-time-hog
          Component|c                           |rtl-optimization

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Is the size of the stack limited on mingw-w64?  If so, try unlimiting it.

We do have gcc.c-torture/compile/limits-fnargs.c in the testsuite which
uses 100000 parameters (albeit it just declares such a function and
calls it with constant arguments).

It works fine here (x86_64-linux) with 28040 arguments and optimization,
but it takes quite some time to compile (the scaling doesn't seem linear
but quadratic at least... :/).

time-report from GCC 5, 28040 arguments and -O1:

Execution times (seconds)
 phase opt and generate  :  97.58 (100%) usr   0.15 (68%) sys  97.73 (100%)
wall  100442 kB (90%) ggc
 forward prop            :  29.33 (30%) usr   0.03 (14%) sys  29.36 (30%) wall 
  3942 kB ( 4%) ggc
 combiner                :  32.60 (33%) usr   0.03 (14%) sys  32.63 (33%) wall 
 14237 kB (13%) ggc
 integrated RA           :  33.77 (35%) usr   0.05 (23%) sys  33.79 (35%) wall 
 26565 kB (24%) ggc
 TOTAL                 :  97.66             0.22            97.88            
111079 kB

I have a stack limit of 8MB configured.


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

end of thread, other threads:[~2015-06-02  9:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-01 21:58 [Bug c/66370] New: compiler crashes when compiling a function with a huge number of arguments jcarbaut at hotmail dot fr
2015-06-02  9:03 ` [Bug rtl-optimization/66370] " rguenth 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).