This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/14112] New: Problem with Multi Threading safety in GCC 2.95.2


We have a huge multi-threaded C++ application built on Solaris using
gcc version = 2.95.2.
libstdc++ 2.10.0
OS: SunOS 5.8

Problem:
Our customer has deployed it on a huge testing environment with 20 concurrent 
users at the same time. Our application ran for a long time and crashed with 
core dump as follows:

-----------------  lwp# 24 / thread# 28  --------------------
 fd536e60 _IO_un_link (4fe0888, 0, 1, 1, 3, 0) + 4c
 fd5377f8 _IO_default_finish (4fe0888, 0, 1, 1, 3f7d60, 25) + 74
 fd542ca0 _._9streambuf (4fe0888, 2, 1, 1, 3, 311239) + 24
 fd53bb8c _._7filebuf (4fe0888, 2, fffffffc, ffac, 0, 0) + 64
 fd54db58 _._8ofstream (4fe0884, 2, fa2094a8, ff167fe0, 0, 25) + 108

The same application did not crash when tried with 10 concurrent users BUT 
application crashed 2 or 3 times in a week by increasing concurrent users.

Where is the crash:
In a constructor of Class C, we are creating an object of ofstream say ofX.
We are Not using ofstream object ofX anywhere in the code.
Calling destructor of Class C, which in turn is calling destructor of ofstream 
object ofX.
Destructor of ofstream object ofX is producing crash as shown above in some 
cases rarely with large no of users.

When the above thread is in destructor of ofstream, there is another thread 
doing some fstream operation, which is not related to crashing thread at all. 
Its details in pstack are:

-----------------  lwp# 21 / thread# 12  --------------------
 fd49d1cc __open   (fc85f83c, 109, 1b4, fd4bc004, 0, 0) + 8
 fde5a75c open     (fb9c90a4, fc85f83c, a, 1b4, fb9c90f4, fd54dd64) + 34
 fd53c2a8 __11fstreambaseiPCcii (fb9c90a0, 0, fc85f83c, a, 1b4, 20) + 12c
 fc842e60 Log_Msg__FUiUiPCc (1, 0, fb9c91d8, 7efefeff, 81010100, ff00) + b8

Other than above 2 threads, no other thread is interesting.

What we suspect?
=================
==================

I was searching in gnu.org to see why crash is happening in destructor of 
ofstream object which is not used at any point in the following calls in stack 
trace 1 provided above:
fd536e60 _IO_un_link (4fe0888, 0, 1, 1, 3, 0) + 4c
fd5377f8 _IO_default_finish (4fe0888, 0, 1, 1, 3f7d60, 25) + 74

I found 2 bug reports:
1. http://gcc.gnu.org/ml/libstdc++/2001-11/msg00071.html
Subject: HELP: GCC 2.95.3 Thread Safe IO

2. http://mail.gnu.org/archive/html/bug-gplusplus/2000-10/msg00035.html
Subject: multi thread libg++ problem

In the above cases, it is mentioned that
a. IO library is not thread safe.
b. When closing two fstreams more or less simulataneously, their application 
crashes at _IO_un_link (at /libio/genops.c). 
c. In bug#1 reply, 
it is given as "In libstdc++-v3 with GCC 3.0, by default the libio/* stuff is 
entirely unused.  Threading largely depends on your C library in 3.0.x.".

Here are my questions:
======================
======================
1. From postings, responses and couple of links, it looks like "gcc version = 
2.95.2. with libstdc++ 2.10.0" is NOT thread safe and is causing the problem.
IS THAT THE CASE??

2. Is it possible to use "gcc version = 2.95.2. with libstdc++ 2.10.0" as 
completely thread safe by some configuration parameters?

3. If we migrate our entire application to "libstdc++-v3 with GCC 3.0", is it 
multi-thread-safe? I have checked "man libc" which is MT-SAFE.

Please respond as early as possible as this is a big problem for us and as we 
have to solve it immediately as the severity is extremely high. Kindly give 
your valuable suggestions on this.

Thanks a lot in advance.
Lakshman.

-- 
           Summary: Problem with Multi Threading safety in GCC 2.95.2
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lakshman_pspl at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org,lakshman_pspl at yahoo
                    dot com


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]