public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* long function name
@ 2005-11-23 17:30 Kornel
  2005-11-30  3:20 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Kornel @ 2005-11-23 17:30 UTC (permalink / raw)
  To: gcc-bugs

Hey,
I know it's not that urgent and as a matter of fact only a theoretical
problem, but still..
g++ crashes for a very long function name ;)

consider this perl program to generate such a stupid-evil source file:

a.pl:
#v+

my $name = "a"x(1024*1024*8);

open( FD, "> test.cpp" ) or die "ohmygawd";

print FD <<EOF

#include <iostream>

void $name(){
        std::cout << "cheers\\n";
}

int main( int argc, char** argv ) {
        $name();
        return 0;
}

EOF
;

print "Compiling..\n";

system "g++ -c test.cpp -o test -Wall -ansi";

#v-

outpus:
Compiling..
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
For Debian GNU/Linux specific bug reporting instructions, see
<URL:file:///usr/share/doc/gcc-4.0/README.Bugs>.


On my system it crashes for 8*1024*1024 chars. I guess this number is
very depended on the actual pc configuration.

 $ g++ -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.0 --enable-__cxa_atexit
--enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release
i486-linux-gnu
Thread model: posix
gcc version 4.0.2 (Debian 4.0.2-2)

I know it's stupid but java for instance does not simply allow longer
names than 65535 (iirc).

--
Cheers,
Kornel


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

* Re: long function name
  2005-11-23 17:30 long function name Kornel
@ 2005-11-30  3:20 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2005-11-30  3:20 UTC (permalink / raw)
  To: Kornel; +Cc: gcc-bugs

Kornel wrote:
> g++ crashes for a very long function name ;)

Bugs should be filed into bugzilla, rather than mailed to the gcc-bugs 
list.  We won't track bugs mailed to the list.

I took a quick look.  I couldn't reproduce on my system.  However, it 
occured to me that gcc is probably trying to copy function names into 
buffers on the stack.  An 8MB function name means you need more than 8MB 
of stack space to compile it.  Experimenting, I can compile the file 
with 16MB of stack space, but I can reproduce your error if I have only 
8MB of stack space.

Since stack space restriction is an OS limit, there isn't much gcc can 
do about it, except to ask you to increase it or reduce your function 
name length.  It isn't reasonable to rewrite code to reduce stack space 
for this example.  If you are using bash, try "ulimit -s unlimited".  If 
there is a per user system specified stack space limit, then you might 
need root access to increase it past this limit.
-- 
Jim Wilson, GNU Tools Support, http://www.specifix.com


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

end of thread, other threads:[~2005-11-30  3:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-23 17:30 long function name Kornel
2005-11-30  3:20 ` Jim Wilson

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