[Bug libstdc++/31117] c++locale.o thread-unsafe in libstdc++

craig dot lawson at centrify dot com gcc-bugzilla@gcc.gnu.org
Wed Mar 14 18:14:00 GMT 2007



------- Comment #10 from craig dot lawson at centrify dot com  2007-03-14 18:13 -------
Found it.

The problem is that the library is not be ing properly compiled for
multi-threaded use, but that by some luck basic_file.cc happened to be compiled
that way anyway. c++locale.cc was not so lucky.

There are two possible solutions.

The solution I believe is best is to compile with the -pthread option. This is
what GNU's own documentation recommends for building MT-compatible objects, and
is designed to be supported across all platforms. This option defines the
appropriate CPP symbol which causes the errno function to be declared rather
than the errno global int. I'm not sure where to insert this flag in configure.
If you can tell me, I can try it out.

The next best solution is to add 

      #include <bits/c++config.h>
      #include <clocale>

to the top of <cerrno> before it includes <errno.h>. These files define the
same CPP symbol as -pthread. However, I'm not confident that <clocale> will do
the job on all platforms. Someone who knows better should evaluate this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31117



More information about the Gcc-bugs mailing list