Symptoms are:

FAIL: gcc.dg/cpp/direct2.c (test for excess errors)
FAIL: gcc.dg/cpp/direct2s.c (test for excess errors)

on sparc64-solaris2.* (not visible on sparc-solaris2.* with -m64).


Parser obstack memory is wrongly reused, leading to memory corruption. 
Reproducible on x86_64-suse-linux:

c-decl.c:start_function

  nstack_vm = XOBNEW (&parser_obstack, struct c_label_context_vm);
  nstack_vm->labels_def = NULL;
  nstack_vm->labels_used = NULL;
  nstack_vm->scope = 0;
  nstack_vm->next = label_context_stack_vm;
  label_context_stack_vm = nstack_vm;

On second stop, we have:

(gdb) p label_context_stack_vm
$9 = (struct c_label_context_vm *) 0x1375008
(gdb) p *label_context_stack_vm
$10 = {labels_def = 0x0, labels_used = 0x0, scope = 0, next = 0x1375008}

On SPARC 64-bit, the labels_used and scope fields are later corrupted in
build_function_declarator:

  struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator);
  ret->kind = cdk_function;
  ret->declarator = target;
  ret->u.arg_info = args;

Parser obstack memory is wrongly freed in c_parser_translation_unit, but I don't
know enough of the new C parser to debug it myself.

-- 
           Summary: Memory management problem in new C parser
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ebotcazou at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: *-*-*
  GCC host triplet: *-*-*
GCC target triplet: *-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21879

Reply via email to