Iterate by index in auto_load_safe_path_vec_update
authorSimon Marchi <simon.marchi@ericsson.com>
Tue, 10 Apr 2018 20:50:59 +0000 (16:50 -0400)
committerSimon Marchi <simon.marchi@ericsson.com>
Tue, 10 Apr 2018 20:50:59 +0000 (16:50 -0400)
commit6e22e10d63addd60f39114cef81ade290b15b2c8
tree82ad95e0d583b81297d7cf7c1dc487f4cc19348a
parentf50d8a2eaea045cd6e9b8d6d5cf8da55e2047ffb
Iterate by index in auto_load_safe_path_vec_update

As reported by Jan, we get this error when building with -D_GLIBCXX_DEBUG:

/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
    }

The bug was introduced by commit

commit e80aaf6183c6692ecc167bf26cbdc53f8f1a55f0
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

The problem is that we iterate using a range-based for on a vector to
which we push in the loop.  Pushing to the vector invalidates the
iterator used in the loop.  Instead, change the code to iterate by index
as was done in the previous code.

gdb/ChangeLog:

* auto-load.c (auto_load_safe_path_vec_update): Iterate by
index.
gdb/ChangeLog
gdb/auto-load.c
This page took 0.026569 seconds and 4 git commands to generate.