public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17301] New: GCC seg faults on legal C code
@ 2004-09-02 22:44 chris at chrisseaton dot com
  2004-09-02 22:51 ` [Bug c/17301] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: chris at chrisseaton dot com @ 2004-09-02 22:44 UTC (permalink / raw)
  To: gcc-bugs

GCC seg faults on what I think is legal C code. Shouldn't seg fault even if it
isn't legal.

This is all very tame code. Most of it is just simple structures and function
stubs. The only unsusual thing here is the use of __builtin_stdarg_start et al.
Still shouldn't be seg faulting though...

I'm running Fedora Core 2, which is Linux 2.6, GCC 3.3.3.

gcc -v follows

Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --disable-libunwind-exceptions --with-system-zlib
--enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)

Preprocessed code follows

When I "gcc -c foo" it seg faults with "internal compiler error".

// /usr/lib/gcc-lib/i386-redhat-linux/3.3.3/cc1 -quiet -D__GNUC__=3
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=3 -DIA_32 format.c -quiet -dumpbase
format.c -auxbase-strip format.o -gstabs -std=c99 -ffreestanding -fno-builtin
-fomit-frame-pointer -o - -frandom-seed=0
# 1 "format.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "format.c"




# 1 "format.h" 1







# 1 "stream.h" 1







# 1 "memory.h" 1
# 10 "memory.h"
typedef signed int size_t;

typedef int bool;
# 9 "stream.h" 2
# 18 "stream.h"
typedef struct
{
        int (*seek)(void* handle, int origin, size_t offset);
        size_t (*tell)(void* handle);

        int (*read)(void* handle, void* buffer, size_t size);
        int (*write)(void* handle, void* buffer, size_t size);

        int (*close)(void* handle);
} StreamInterface;

typedef struct
{
        void* handle;
        StreamInterface* interface;
} Stream;

Stream* stream_open(void* handle, StreamInterface* interface);
int stream_seek(Stream* stream, int origin, size_t offset);
size_t stream_tell(Stream* stream);
int stream_read(Stream* stream, void* buffer, size_t size);
int stream_write(Stream* stream, void* buffer, size_t size);
int stream_close(Stream* stream);
# 9 "format.h" 2

int write_format(Stream* stream, char* format, ...);
int write_format_list(Stream* stream, char* format, __builtin_va_list parameters);

int write_int(Stream* stream, int value);
int write_string(Stream* stream, char* string);
# 6 "format.c" 2

int write_format(Stream* stream, char* format, ...)
{
        __builtin_va_list parameters;

        __builtin_stdarg_start(parameters);
        int code = write_format_list(stream, format, parameters);
        __builtin_va_end(parameters);

        return code;
}

int write_format_list(Stream* stream, char* format, __builtin_va_list parameters)
{
        return 0;
}

int write_int(Stream* stream, int value)
{
        return 0;
}

int write_string(Stream* stream, char* string)
{
        return 0;
}

-- 
           Summary: GCC seg faults on legal C code
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chris at chrisseaton dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] GCC seg faults on legal C code
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
@ 2004-09-02 22:51 ` pinskia at gcc dot gnu dot org
  2004-10-10  0:54 ` [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start pinskia at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-02 22:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-02 22:51 -------
Confirmed here is the reduced testcase, this is invalid code as __builtin_stdarg_start takes two 
arguments:
int write_format(char* format, ...)
{
        __builtin_va_list parameters;
        __builtin_stdarg_start(parameters);
}
Not a regression.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |ice-on-invalid-code
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-02 22:51:30
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
  2004-09-02 22:51 ` [Bug c/17301] " pinskia at gcc dot gnu dot org
@ 2004-10-10  0:54 ` pinskia at gcc dot gnu dot org
  2004-10-10  1:10 ` cvs-commit at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-10  0:54 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-10 00:54 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00839.html>.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
  2004-09-02 22:51 ` [Bug c/17301] " pinskia at gcc dot gnu dot org
  2004-10-10  0:54 ` [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start pinskia at gcc dot gnu dot org
@ 2004-10-10  1:10 ` cvs-commit at gcc dot gnu dot org
  2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-10  1:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-10 01:10 -------
Subject: Bug 17301

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsm28@gcc.gnu.org	2004-10-10 01:10:53

Modified files:
	gcc            : ChangeLog builtins.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr17301-1.c 

Log message:
	PR c/17301
	* builtins.c (expand_builtin_va_start): Check for too few
	arguments to va_start.
	
	testsuite:
	* gcc.dg/pr17301-1.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5824&r2=2.5825
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/builtins.c.diff?cvsroot=gcc&r1=1.399&r2=1.400
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4425&r2=1.4426
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr17301-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
                   ` (3 preceding siblings ...)
  2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
@ 2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
  2004-10-11  8:52 ` reichelt at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-10  2:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-10 02:06 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
                   ` (2 preceding siblings ...)
  2004-10-10  1:10 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
  2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-10  2:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-10 02:06 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
                   ` (4 preceding siblings ...)
  2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
@ 2004-10-11  8:52 ` reichelt at gcc dot gnu dot org
  2004-10-11 11:49 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2004-10-11  8:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From reichelt at gcc dot gnu dot org  2004-10-11 08:52 -------
Joseph, your fix is only a partial one. We still ICE if no argument at all
is passed to __builtin_stdarg_start:

=================================
void foo (char *format, ...)
{
  __builtin_stdarg_start ();
}
=================================

bug.c: In function `foo':
bug.c:3: error: too few arguments to function `__builtin_stdarg_start'
bug.c:3: internal compiler error: Segmentation fault
Please submit a full bug report, [etc.]


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu dot org
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
                   ` (5 preceding siblings ...)
  2004-10-11  8:52 ` reichelt at gcc dot gnu dot org
@ 2004-10-11 11:49 ` pinskia at gcc dot gnu dot org
  2004-10-12  8:32 ` cvs-commit at gcc dot gnu dot org
  2004-10-12 11:42 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-11 11:49 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|REOPENED                    |NEW
   Target Milestone|4.0.0                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
                   ` (6 preceding siblings ...)
  2004-10-11 11:49 ` pinskia at gcc dot gnu dot org
@ 2004-10-12  8:32 ` cvs-commit at gcc dot gnu dot org
  2004-10-12 11:42 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-10-12  8:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-10-12 08:32 -------
Subject: Bug 17301

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jsm28@gcc.gnu.org	2004-10-12 08:32:17

Modified files:
	gcc            : ChangeLog c-typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: pr17301-2.c 

Log message:
	PR c/17301
	* c-typeck.c (convert_arguments): Return error_mark_node if there
	are too few arguments.
	(build_function_call): Handle error_mark_node return from
	convert_arguments.
	
	testsuite:
	* gcc.dg/pr17301-2.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5841&r2=2.5842
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.388&r2=1.389
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4439&r2=1.4440
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr17301-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

* [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start
  2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
                   ` (7 preceding siblings ...)
  2004-10-12  8:32 ` cvs-commit at gcc dot gnu dot org
@ 2004-10-12 11:42 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-12 11:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-12 11:42 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17301


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

end of thread, other threads:[~2004-10-12 11:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 22:44 [Bug c/17301] New: GCC seg faults on legal C code chris at chrisseaton dot com
2004-09-02 22:51 ` [Bug c/17301] " pinskia at gcc dot gnu dot org
2004-10-10  0:54 ` [Bug c/17301] ICE on wrong usage of __builtin_stdarg_start pinskia at gcc dot gnu dot org
2004-10-10  1:10 ` cvs-commit at gcc dot gnu dot org
2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
2004-10-10  2:06 ` pinskia at gcc dot gnu dot org
2004-10-11  8:52 ` reichelt at gcc dot gnu dot org
2004-10-11 11:49 ` pinskia at gcc dot gnu dot org
2004-10-12  8:32 ` cvs-commit at gcc dot gnu dot org
2004-10-12 11:42 ` pinskia at gcc dot gnu dot 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).