[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#458745: arm-only miscompilation of alloca code



Herbert, do you think you could take a quick long at this bug report
before I forward it upstream to the GCC folks?


* Camm Maguire <camm@enhanced.com> [2008-01-02 10:09]:
> Package: gcc-4.2
> Version: 4.2.2-4
> Severity: important
> 
> /tmp/foo.c:
> =============================================================================
> #include <stdio.h>
> #include <alloca.h>
> #include <stdarg.h>
> #define object void *
> 
> int VFUN_NARGS;
> void *alloca_val;
> struct cons {
>   object c_cdr;
>   object c_car;
> };
> 
> #define Cnil 0
> 
> static void
> foo(object first,...) {
>   va_list ap;
>   int narg = VFUN_NARGS;
>   struct cons *V1128;
>   object V1129;
> 
>   va_start(ap,first);
>   V1129 = 
>     !narg? Cnil : (alloca_val=alloca((narg)*sizeof(struct cons)+sizeof(object)),
> 		   ({object _b=(void *)alloca_val;if (((unsigned long)_b)&sizeof(_b)) _b++;
> 		   {register struct cons *_p=(void *)_b;
> 		   {struct cons *_e=_p+(narg-1);
> 		   for (;_p<_e;_p++) {_p->c_car=({object _t=first;first=va_arg(ap,object);_t;});_p->c_cdr=(object)(_p+1);}}
> 		   _p->c_car=first;_p->c_cdr=Cnil;}_b;}));
>   va_end(ap);
>   V1128= V1129;
>   for (;V1128!=Cnil;V1128=V1128->c_cdr)
>     printf("%p\n",V1128->c_car);
> 
> }
> 
> int
> main(int argc,char * argv[]) {
> 
>   VFUN_NARGS=4;
>   foo(&argc,1,2,3);
>   return 0;
> 
> }
> =============================================================================
> i386 sid:
> =============================================================================
> cc -g /tmp/foo.c -o /tmp/foo
> /tmp/foo
> 0xbf867bd0
> 0x1
> 0x2
> 0x3
> =============================================================================
> leisner dchroot sid:
> =============================================================================
> cc -g foo.c -o foo
> ./foo
> 0x18beed5d
> Segmentation fault
> =============================================================================
> 
> Take care,
> 
> -- System Information:
> Debian Release: lenny/sid
>   APT prefers unstable
>   APT policy: (500, 'unstable')
> Architecture: i386 (i686)
> 
> Kernel: Linux 2.6.20-gen
> Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
> Shell: /bin/sh linked to /bin/bash
> 
> Versions of packages gcc-4.2 depends on:
> ii  binutils            2.18.1~cvs20071027-1 The GNU assembler, linker and bina
> ii  cpp-4.2             4.2.2-4              The GNU C preprocessor
> ii  gcc-4.2-base        4.2.2-4              The GNU Compiler Collection (base 
> ii  libc6               2.7-2                GNU C Library: Shared libraries
> ii  libgcc1             1:4.2.2-4            GCC support library
> ii  libgomp1            4.2.2-4              GCC OpenMP (GOMP) support library
> 
> Versions of packages gcc-4.2 recommends:
> ii  libc6-dev                     2.7-2      GNU C Library: Development Librari
> 
> -- no debconf information
> 

-- 
Martin Michlmayr
http://www.cyrius.com/



Reply to: