This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/16612] empty basic_strings can't live in shared memory
- From: "steve dot horn at gs dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jul 2004 01:31:05 -0000
- Subject: [Bug libstdc++/16612] empty basic_strings can't live in shared memory
- References: <20040718033747.16612.steve.horn@gs.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From steve dot horn at gs dot com 2004-07-22 01:31 -------
It crashes on me. Below is what I see in gdb for the 'test' executable.
Note that for the empty string created in 'test-bigger' (e.g. header->string3) _M_p is
<Address 0x40642c out of bounds>
For the empty string declared in 'test', _M_p is 0x642c ""
The non-empty strings populated in 'test-bigger' are all in 'test's address space.
Calling mmap(addr=0x6400000, size=65536, mprod=3, mflags=1, fd=6, offset=0);
mmap succeeded!
Got the requested address.
First string: [hello world]
Second string: [foo bar]
Breakpoint 3, main (argc=1, argv=0xbffffb44) at test.C:53
53 std::cout << "Third string: [" << *header->string3 << "]" << std::endl;
(gdb) p emptyString
$4 = {
static npos = <optimized out>,
_M_dataplus = {
<ShmAllocator<char>> = {<No data fields>},
members of basic_string<char,std::char_traits<char>,ShmAllocator<char> >::_Alloc_hider:
_M_p = 0x642c ""
}
}
(gdb) p header->string3
$5 = (ShmString *) 0x640002c
(gdb) p *header->string3
$6 = {
static npos = <optimized out>,
_M_dataplus = {
<ShmAllocator<char>> = {<No data fields>},
members of basic_string<char,std::char_traits<char>,ShmAllocator<char> >::_Alloc_hider:
_M_p = 0x40642c <Address 0x40642c out of bounds>
}
}
(gdb) p *header->string2
$7 = {
static npos = <optimized out>,
_M_dataplus = {
<ShmAllocator<char>> = {<No data fields>},
members of basic_string<char,std::char_traits<char>,ShmAllocator<char> >::_Alloc_hider:
_M_p = 0x6400064 "foo bar"
}
}
(gdb) n
Program received signal EXC_BAD_ACCESS, Could not access memory.
0x0000361c in std::basic_string<char, std::char_traits<char>, ShmAllocator<char> >::size() const
(this=0x640002c) at /Users/horns/gcc-3.4.1/lib/gcc/powerpc-apple-darwin7.4.0/3.4.1/../../../../
include/c++/3.4.1/bits/basic_string.h:532
532 size() const { return _M_rep()->_M_length; }
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16612