This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cpp segfaults during bootstrap on ARM... (fwd)


On Fri, Apr 28, 2000 at 12:53:22PM -0400, Scott Bambrough wrote:
> Zack Weinberg wrote:
> 
> > A failure in chunk_alloc probably means cpp scribbled on malloc's data
> > structures.  I've had good luck tracking these down with Electric
> > Fence, if you have that available.  Libc's malloc also has a
> > paranoid mode, but it isn't nearly as good.
> 
> Thanks for the tip.  I tracked down the problem using ElectricFence.
> 
> /* lines 534-550 from gcc/cpplex.c */
> 
>       if (list->name_used + len >= list->name_cap)
>         auto_expand_name_space (list);
> 
>       if (type == CPP_MACRO)
>         type = CPP_NAME;
> 
>       list->tokens_used++;
>       list->tokens[i].type = type;
>       list->tokens[i].col = col;
>       list->tokens[i].flags = space_before ? PREV_WHITESPACE : 0;
>       
>       if (type == CPP_VSPACE)
>         break;
> 
>       list->tokens[i].val.name.len = len;
>       list->tokens[i].val.name.offset = list->name_used;
>       memcpy (list->namebuf + list->name_used, CPP_PWRITTEN (pfile), len);


> The memory violation occurs during the memcpy at line 550.  The
> problem is the use of auto_expand_name_space().  When I crash
> name_used is 17, len = 2141 and name_cap = 1536.
> auto_expand_name_space only increases name_cap by 1536/2 to 2304
> bytes.  We actually need 2158 bytes.

I thought I saw a similar complaint go by but I couldn't reproduce
it.  Thanks for the analysis.

Your patch is fine.

zw

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]