Your message dated Tue, 20 Dec 2011 14:30:54 +0100
with message-id <4ef08e0e.9050...@debian.org>
and subject line Re: Bug#603113: all my apologies
has caused the Debian Bug report #603113,
regarding libstdc++6: SIGSEGV in sort(rndit, rndit,cmp) with cmp modifying
vector outside boundaries
to be marked as done.
This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.
(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)
--
603113: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=603113
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
Package: libstdc++6
Version: 4.4.5-6
Severity: normal
The following code segfaults when copying rhs in cmp::operator()
because it's a dangling reference. it appends at the 2nd iteration.
It worked previously but I can't say since how long it does not work,
recently I guess.
Yet it should be possible to manipulate the vector during the comparison
if we take care to do so outside the limits imposed by the iterators.
Best regards,
Guillaume
---------8<--------------
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
class cmp : binary_function<bool,string,string> {
vector<string>& vec;
public:
cmp(vector<string>& v) : vec(v) {}
bool operator()(const string& lhs, const string& rhs) {
vec.push_back("ping");vec.push_back("pong");
vec.pop_back();vec.pop_back();
return lhs<rhs;
}
};
int main(int argc, char **argv) {
vector<string> vec;
vec.push_back("lundi"); vec.push_back("mardi");
vec.push_back("mercredi"); vec.push_back("jeudi");
vec.push_back("vendredi"); vec.push_back("samedi");
vec.push_back("dimanche");
sort(vec.begin(),vec.end(),cmp(vec));
return 0;
}
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1,
'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.34-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libstdc++6 depends on:
ii gcc-4.4-base 4.4.5-6 The GNU Compiler Collection
(base
ii libc6 2.11.2-7 Embedded GNU C Library:
Shared lib
ii libgcc1 1:4.4.5-6 GCC support library
libstdc++6 recommends no packages.
libstdc++6 suggests no packages.
-- no debconf information
--- End Message ---
--- Begin Message ---
On 11/11/2010 01:30 AM, Guillaume Gimenez wrote:
> I reply to myself because it's my own bug...
>
> In this precise case, iterators are invalidated due to a reallocation.
> The vector grew up in the callback to what was already reserved
>
> file:///usr/share/doc/stl-manual/html/Vector.html#5
closing
--- End Message ---