This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Invalid tree node causes segfault in diagnostic
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Paulo Matos <pmatos at broadcom dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Fri, 11 Oct 2013 14:46:32 +0200
- Subject: Re: Invalid tree node causes segfault in diagnostic
- Authentication-results: sourceware.org; auth=none
- References: <19EB96622A777C4AB91610E763265F462DA932 at SJEXCHMB14 dot corp dot ad dot broadcom dot com>
On Fri, Oct 11, 2013 at 12:57 PM, Paulo Matos <pmatos@broadcom.com> wrote:
> Hello,
>
> I have a testcase that, during parsing, generates an invalid tree. This invalid tree triggers tree_check_failed, which was expecting a string_cst.
> tree_check_failed calls internal_error with tree_code_name[TREE_CODE (node)] without checking that TREE_CODE (node) is valid.
>
> I attach a patch as a suggestion of a fix. I would like some comments.
>
> This patch eliminates the segfault and generates the error:
> ../../../../../source/adsl-mech/components/common/PsdInfo.c:717:1: internal compiler error: tree check: expected string_cst, have (invalid code name) in get_named_section, at varasm.c:415
>
> This is obviously another thing I still have to understand why it's happening.
> The testcase is still too big (1Mb) and I haven't reproduced it with any upstream port so I am not reporting a bug yet.
Hmm. We have several places accessing tree_code_name without checking.
May I suggest to abstract accesses to it with a function call which can
do the proper checking and return "<invalid tree code>" instead?
Thanks,
Richard.
> For the patch attached:
>
> 2013-10-11 Paulo Matos <pmatos@broadcom.com>
>
> * tree.c (tree_check_failed): Check that TREE_CODE is valid before
> passing it to tree_code_name.
>
>
> Paulo Matos
>
>