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

Bug#349268: gcc-4.0: ICE building clisp on amd64.



On Sun, Jan 22, 2006 at 01:42:52PM +0100, Bastian Blank wrote:
> On Sat, Jan 21, 2006 at 10:57:13PM +0100, Kurt Roeckx wrote:
> > I've reduce the code in question to:
> > int x;
> > static void ** STACK;
> 
> Two uninitialized variables.
> 
> > static void get_block () {
> >   while (1)
> >   {
> >     STACK[0] = (void *)(&x+(1L<<48));
> 
> - Dereference of an uninitialized variable aka undefined behaviour.
> - Producing a pointer which is outside of an object. Don't know if this
>   is UB also.
> 
> >   }
> > }
> 

In the original, both where actually extern.
So it more looked like:
extern int x;
extern void ** STACK;

static void get_block () {
  while (1)
  {
    STACK[0] = (void *)(&x+(1L<<48));
  }
}

The original line of code actually looks like:

extern gcv_object_t* STACK;
[...]
extern struct symbol_tab_ {

  symbol_ S_nil;
  symbol_ S_t;
[...]
  symbol_ S_foreign_call_in;
} symbol_tab_data;
[...]
static void get_block (char block[64], object vector) {
  while (!((((tint)((oint)(vector) >> 48)) & ~(1L<<(3))) == (( (1L<<(4)) ) + ((3)<<0) + ((3)&((1L<<(0+1))-(1L<<(1)))) + ((3)&((1L<<(1+1))-(1L<<(2))))))
         || vector_length(vector) != 8) {
    ((STACK[-1-(sintP)(-1)]) = (((gcv_object_t)(((UBYTE*)((&symbol_tab_data.S_nil))+((oint)(tint)(( (1L<<(2)) ))<<48))))), STACK -= -1);
    ((STACK[-1-(sintP)(-1)]) = (vector), STACK -= -1);
    ((STACK[-1-(sintP)(-1)]) = (module__syscalls__object_tab._object__28vector_20_28unsigned_byte_208_29_208_29), STACK -= -1);
    ((STACK[-1-(sintP)(-1)]) = (((STACK[-1-(sintP)(0)]))), STACK -= -1); ((STACK[-1-(sintP)(-1)]) = (vector), STACK -= -1);
    ((STACK[-1-(sintP)(-1)]) = (((Subr)(((0==0) && ((((oint)(tint)(( (1L<<(0)))) << 48) & ~0UL) == 0) ? (void*)(aint)(oint)(back_trace->bt_function) : (void*)(aint)((void*)((aint)((oint)(back_trace->bt_function)) & ((aint)0x0000FFFFFFFFFFFFUL | ~~0UL))) )))->name), STACK -= -1);
    check_value(type_error,clgettext("~S: ~S is not of type ~S"));
    vector = mv_space[0];
  }
[...]

I do have to agree that the creating of that pointer is
probably undefined behaviour, and it might have more
undefined behaviour with how it's accessing that STACK and
things like that.


Kurt




Reply to: