I am using an svn checkout of 4.5 trying to play with new c++0x features.  I've
tried debugging this myself, but gcc is huge and this is my first foray into
it.  I will list what I know.

My checkout information :

$ svn info
Path: .
URL: svn://gcc.gnu.org/svn/gcc/trunk
Repository Root: svn://gcc.gnu.org/svn/gcc
Repository UUID: 138bc75d-0d04-0410-961f-82ee72b054a4
Revision: 155176
Node Kind: directory
Schedule: normal
Last Changed Author: rguenth
Last Changed Rev: 155174
Last Changed Date: 2009-12-11 13:00:24 -0500 (Fri, 11 Dec 2009)

Running my makefile accomplishes the following :
LD_LIBRARY_PATH=/home/knome/local-gcc/lib /home/knome/local-gcc/bin/g++ -Wall
--pedantic --std=c++0x main.cc
Internal Compiler Error : attempt to lookup fileinfo for NULL.
In static member function ‘static boost::shared_ptr<monad::Monad<InnerType,
RsType> > monad::Monad<InnerType, ChainType>::result(boost::shared_ptr<Y>)
[with RsType = std::basic_string<char>, InnerType = monad::World, ChainType =
monad::Undefined]’:
main.cc:49:65:   instantiated from here
cc1plus: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

The error only occurs when using a lambda with copying variable capture.  A
lambda with no variable capture or reference capture does not trigger the
segfault.

A backtrace shows the source of the segfault seems to be a null tossed into the
splay_tree_lookup function.  I picked around some and found the null was coming
from a LAMBDA_EXPR_LOCATION macro expansion.  I put a watch on the
input_location variable using gdb and the last three locations to update it
before segfault are :

    Old value = 2634207
    New value = 2633833
    tsubst_decl (t=0xb7634400, args=<value optimized out>, complain=3) at
../.././gcc/cp/pt.c:8626
    $113790 = 0x8ce5238 "main.cc"
    Hardware watchpoint 7: input_location

    Old value = 2633833
    New value = 2634207
    tsubst_decl (t=<value optimized out>, args=<value optimized out>,
complain=<value optimized out>) at ../.././gcc/cp/pt.c:9381
    $113791 = 0x8ce5238 "main.cc"
    Hardware watchpoint 7: input_location

    Old value = 2634207
    New value = 0
    build_lambda_object (lambda_expr=0xb7557aa8) at
../.././gcc/cp/semantics.c:5401
    $113792 = 0x0
    Internal Compiler Error : attempt to lookup fileinfo for NULL.

    Program received signal SIGSEGV, Segmentation fault.

The relevant section in sematics.c being :

      if (processing_template_decl)
        return lambda_expr;

      /* Make sure any error messages refer to the lambda-introducer.  */
      saved_loc = input_location;
  >   input_location = LAMBDA_EXPR_LOCATION (lambda_expr);

      for (node = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr);
           node;
           node = TREE_CHAIN (node))
        {
          tree field = TREE_PURPOSE (node);
          tree val = TREE_VALUE (node);

I will continue trying to backtrack this to the source, but felt I should
submit it as a bug so that someone with actual knowledge of gcc can have the
chance to find it before I slowly work my way there.

I've been looking through gcc/cp/parser.c trying to step through and see the
bad assignment.  I will continue with this sort of tracking as I can.


-- 
           Summary: NULL dereference in strcmp at libibery/splay-tree.c:148
                    (segfault)
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: knomenet at gmail dot com


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

Reply via email to