This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Regression with -D_GLIBCXX_DEBUG [Re: [PATCH 1/5] Make delim_string_to_char_ptr_vec return an std::vector]


Hi,

commit e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0 (HEAD)
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Mar 2 23:22:06 2018 -0500
    Make delim_string_to_char_ptr_vec return an std::vector

/usr/include/c++/7/debug/safe_iterator.h:297:
Error: attempt to increment a singular iterator.
Objects involved in the operation:
    iterator "this" @ 0x0x7fffffffd140 {
      type = __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<std::unique_ptr<char, gdb::xfree_deleter<char> >*, std::__cxx1998::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > >, std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > > > (mutable iterator);
      state = singular;
      references sequence with type 'std::__debug::vector<std::unique_ptr<char, gdb::xfree_deleter<char> >, std::allocator<std::unique_ptr<char, gdb::xfree_deleter<char> > > >' @ 0x0x265db40
    }
#4  0x000000000078f893 in auto_load_safe_path_vec_update () at auto-load.c:212


On Sun, 25 Feb 2018 17:32:43 +0100, Simon Marchi wrote:
>    /* Apply tilde_expand and gdb_realpath to each AUTO_LOAD_SAFE_PATH_VEC
>       element.  */
> -  for (ix = 0; ix < len; ix++)
> +  for (gdb::unique_xmalloc_ptr<char> &in_vec : auto_load_safe_path_vec)
>      {
...
> -	  VEC_safe_push (char_ptr, auto_load_safe_path_vec,
> -			 real_path.release ());
> +	  auto_load_safe_path_vec.push_back (std::move (real_path));
>  	}
>      }
>  }

The iterator breaks when moving its std::vector data underneath it.
This is why the original C code did not use a pointer there.


Jan


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