Issue Details (XML | Word | Printable)

Key: STDCXX-127
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Farid Zaripov
Reporter: Liviu Nicoara
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

std::deque::swap does not swap empty containers correctly

Created: 27/Jan/06 06:33 AM   Updated: 01/Nov/07 08:02 PM
Return to search
Component/s: 23. Containers
Affects Version/s: 4.1.3
Fix Version/s: 4.2.0

Time Tracking:
Not Specified

Environment:
$ uname -a
Linux skynet 2.6.14.5 #3 SMP PREEMPT Mon Jan 9 13:59:21 MST 2006 i686 unknown unknown GNU/Linux

$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.2/configure --prefix=/opt/compilers/gcc-4.0.2 --enable-shared --enable-threads --enable-languages=c,c++
Thread model: posix
gcc version 4.0.2

Issue Links:
Reference
 

Resolved: 15/Feb/07 02:41 PM
Resolution Date: 15/Feb/07 02:41 PM


 Description  « Hide
Copy and paste at prompt:

$ cat t.xpp
#include <cstddef>
#include <deque>

struct A { char tmp [32]; };

int main ()
{
A a [32];

std::deque<A> lhs (a, a + 0);
std::deque<A> rhs (a, a + 1);

lhs.swap (rhs);

return 0;
}

Building and running the example leads to a SIGSEGV:

$ make SRCS=t.cpp && ./t
gcc -c -I/build/nicoara/stdcxx/include/ansi -D_RWSTDDEBUG -pthread -D_RWSTD_USE_CONFIG -I/build/nicoara/15s-stdcxx/include -I/build/nicoara/stdcxx/include -I/build/nicoara/stdcxx/../rwtest -I/build/nicoara/stdcxx/../rwtest/include -I/build/nicoara/stdcxx/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align /build/nicoara/stdcxx/tests/containers/t.cpp
gcc t.o -o t -L/build/nicoara/15s-stdcxx/rwtest -lrwtest15s -pthread -L/build/nicoara/15s-stdcxx/lib -lstd15s -lsupc++ -lm
Segmentation fault



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Liviu Nicoara added a comment - 27/Jan/06 06:46 AM
GDB stack trace:

$ gdb t
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-slackware-linux"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) r
Starting program: /build/nicoara/15s-stdcxx/tests/t
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 7497)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 7497)]
0x0804ba87 in std::copy<_rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > >, __rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > > > (_first=@0xbfd52c54, __last=@0xbfd52c48,
__res=@0xbfd52c3c) at _algobase.h:88
88 *_res = *_first;
(gdb) bt
#0 0x0804ba87 in std::copy<_rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > >, __rw::rw_debug_iter<std::deque<A, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> >, std::rw_deque_iter<A, int, A*, A&, std::allocator<A> > > > (_first=@0xbfd52c54,
__last=@0xbfd52c48, __res=@0xbfd52c3c) at _algobase.h:88
#1 0x0804be6b in std::deque<A, std::allocator<A> >::erase (this=0xbfd53130,
__first=@0xbfd52ca8, __last=@0xbfd52c9c) at deque.cc:158
#2 0x0804bf7d in std::deque<A, std::allocator<A> >::clear (this=0xbfd53130)
at deque:644
#3 0x0804c028 in ~deque (this=0xbfd53130) at deque:476
#4 0x08049d30 in main () at /build/nicoara/stdcxx/tests/containers/t.cpp:15
(gdb)


Farid Zaripov added a comment - 15/Feb/07 02:41 PM

Farid Zaripov added a comment - 06/Jun/07 10:01 AM
The regression test added thus: http://svn.apache.org/viewvc?view=rev&rev=544791