This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpp segfaults during bootstrap on ARM... (fwd)
- To: Scott Bambrough <scottb at netwinder dot org>
- Subject: Re: cpp segfaults during bootstrap on ARM... (fwd)
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Fri, 28 Apr 2000 10:37:45 -0700
- Cc: gcc patches mailing list <gcc-patches at gcc dot gnu dot org>
- References: <E12kiq6-0002Iw-00@fountain.labs.futuretv.com> <20000427005505.I12153@wolery.cumb.org> <3909C202.64E4765@netwinder.org>
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