- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: map<string,vector <string> > causing segmentat...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2007 04:44 PM
тАО01-02-2007 04:44 PM
void test::runMap()
{
using std::string;
std::map
std::vector
mymap=new std::map
map
std::vector
myvec.push_back("First");
myvec.push_back("Second");
string tmp("key1");
(*mymap)[tmp]=myvec; //// SEG FAULT occurs here
// mymap->insert( make_pair( tmp, myvec ) ); //////THIS WORKS with no Segmentation fault
it1 = (*mymap).find(tmp);
std::cout << "Printing contents of vector of size : " << myvec.size();
for(i=myvec.begin(); i!=myvec.end(); ++i){
std::cout<<(*i)<<:endl>
}
I have the following problem in my code using std::map
aCC -v -AA +Z -mt -o for linker options..
During running,
The line (*mymap)[tmp]=myvec gives rise to segmentation fault problem (core dumped) which leads to terminate>abort.. This occurs for apparently no reason.. Also when I replace this with mymap->insert( make_pair( tmp, myvec ) ); , the problem doesn't occur..
But I cannot replace the former with the latter because of its known limitations & also since I will have to replace the major part of my modules & across translation units. But since the latter works (which in most cases is similar to former case), there doesn't seem any memory corruption happening which I have checked with gdb & stack trace..
With std::map<:string> & other simple types, this error doesn't arise. It only occurs when the second element of map is some STL, like vector or may be set also. For this case, operator= is not working as desired.
Is this a known issue in HP-UX. Is there any need of system STL libraries patch or OS or compiler patch required. Also, this code has worked & run in Solaris, Windows & other platforms, so why is it failing only in HP-UX.
The stack trace which will will at the least show what is the error is related to..:--
#0 0xc02110d8 in kill+0x10 () from /usr/lib/libc.2
#1 0xc01a86c4 in raise+0x24 () from /usr/lib/libc.2
#2 0xc01eb49c in abort_C+0x15c () from /usr/lib/libc.2
#3 0xc01eb4f4 in abort+0x1c () from /usr/lib/libc.2
#4 0x86c48 in std::terminate+0x30 ()
#5 0x7ee5c in ThrowException+0x68 ()
#6 0x7f2dc in __throw__FPvT1+0xf0 ()
#7 0x3b014 in std::basic_string
at /opt/aCC/include_std/string:1003
#8 0x46408 in std::basic_string
__str=@0x4001cc50) at /opt/aCC/include_std/string.cc:267
#9 0x44760 in std<:basic_string>,std::allocator
at /opt/aCC/include_std/algorithm:1979
#10 0x41e0c in std::vector<:basic_string>,std::allocator
at /opt/aCC/include_std/vector.cc:88
#11 0x3fd64 in test::runMap (this=0x7f7f0a75) at test.cpp:27
#12 0x3b454 in main (argc=1, argv=0x7f7f08ec) at mymain.cpp:27
Please provide suggestions which may resolve or may aid in tracking down the problem. In case any more clarifications about the code/platform etc, please write down.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2007 05:19 PM
тАО01-02-2007 05:19 PM
Re: map<string,vector <string> > causing segmentation fault
It never hurts to have a system fully patched in order to avoid this being a contributing factor to issues.
There are a number of patches in the bi-annual patch set for HP-UX 11.11 and 11.23 that could impact this issue.
Using a debugger also sounds like a good idea in this case.
Good Luck,
Have fun,
Thanks for using ITRC.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2007 11:48 PM
тАО01-03-2007 11:48 PM
Re: map<string,vector <string> > causing segmentation fault
The throw in frame #7 is probably due to the fact that you have not compiled EVERYTHING with -mt. You must make sure all of your objects, archives and shlibs are compiled with -mt.
On IPF, you get a nice message indicating this.
For PA, if you compile with +d, you'll get the exact location of the throw. string:1003 just got through destroying the string.
>-w
You really should NOT be using -w. Instead use +W### to suppress individual messages.
You do know that if you have a map of a STL container, you are going to copy the WHOLE STL container into the map? Using a pointer to an existing container would prevent the copy. But you would have to know when to clean up the space.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2007 09:50 PM
тАО01-08-2007 09:50 PM
Solutionhttp://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,1743,00.html#11.11
Note I get signal 11 instead of the throw.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-09-2007 03:33 PM
тАО01-09-2007 03:33 PM