About multi-threading and -D_GLIBCXX_DEBUG

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 31
Reputation: rmlopes is an unknown quantity at this point 
Solved Threads: 0
rmlopes rmlopes is offline Offline
Light Poster

About multi-threading and -D_GLIBCXX_DEBUG

 
0
  #1
Jul 9th, 2009
Hi everybody,

I am having some problems with a multi-threaded application I am developing. I get segmentation faults in different places, always related to std::string, using g++4.3.2 on Ubuntu 8.10 server. Here is an example:
#0  0xb7e18bb6 in memcpy () from /lib/tls/i686/cmov/libc.so.6
(gdb) up
#1  0xa8eb1014 in ?? ()
(gdb) up
#2  0xb7fca1ef in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string () from /usr/lib/libstdc++.so.6

The obvious to think is that std::string is not thread safe (and I use this extensively). I couldn't find very recent threads on the web about this, but I found an advice to compile with the flag -D_GLIBCXX_DEBUG.
This flag indeed eliminates (at least apparently) the concurrency issue with the strings.
I tried the application in windows VC++ 2008 and in this platform everything works fine [EDITED]in DEBUG mode only, although I didn't specifically set the flag.[/EDITED]

I couldn't find much info on this and there are some questions I would like to have answered like:
  • What changes in concrete when we use the flag?
  • It is still a debug mode so, will it degrade the performance if compiled without -g and with -D_GLIBCXX_DEBUG?
  • Why is windows std::string thread safe and not g++?
  • Any other solutions for this issue?

Thanks in advance
Last edited by rmlopes; Jul 9th, 2009 at 12:50 pm. Reason: See the tags EDITED
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 28
Reputation: ganbree is an unknown quantity at this point 
Solved Threads: 0
ganbree ganbree is offline Offline
Light Poster

Re: About multi-threading and -D_GLIBCXX_DEBUG

 
0
  #2
Jul 9th, 2009
Try the compiler flag.

--enable-threads

I don't use gcc regularly so I have no idea what -D_GLIBXX_DEBUG does, this might or might not solve the problem.

Thanks in advance; in advance, taken.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 191 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC