bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hang in ostrstream::operator<<(int n)


From: Geoff Alexander
Subject: Re: hang in ostrstream::operator<<(int n)
Date: 21 Jan 2002 23:41:05 -0800

address@hidden (?iso-8859-1?Q?Andr?P?itz?) wrote: > Geoff Alexander
<address@hidden> wrote:
> The "upgrade" could be as easy as putting a 'sstream' file with appropria
> te
> content into /usr/include/g++.
> 
> http://mathematik.htwm.de/tmp/sstream  should do for starters...
> 
> Andre'

Thanks for the suggestion.  I also received e-mail saying I could get
ostringstream by upgrading to gcc 2.95.3 as well.  However, I'd like
to understand why ostrstream::operator<<(int n) is hanging in case
something serious is going on.  I traced the code under DDD/GDB and
found the following:

1. ostrstream::ostrstream() calls strstreambuf::strstreambuf() which
   calls streambuf::streambuf(int flags) which allocates an
   _IO_lock_t:

     streambuf::streambuf(int flags)
     {
     #ifdef _IO_MTSAFE_IO
       _lock = new _IO_lock_t;
     #endif
       _IO_init(this, flags);
     #if !_IO_UNIFIED_JUMPTABLES
       _jumps = &_IO_streambuf_jumps;
     #endif
     }
 
2. ostrstream::operator<<(int n), inherited from
   ostream::operator<<(int n), calls
   ostream::write_int(ostream& stream, unsigned LONGEST val,
   int sign) which calls ostream::opfx() which calls
   __flockfile(*FILE stream) which calls
   __pthread_mutex_unlock(pthread_mutex_t * mutex):

     void
     __flockfile (FILE *stream)
     {
     #ifdef USE_IN_LIBIO
       __pthread_mutex_lock (stream->_lock);
     #else
     #endif
     }
     #ifdef USE_IN_LIBIO
     #undef _IO_flockfile
     strong_alias (__flockfile, _IO_flockfile)
     #endif
     weak_alias (__flockfile, flockfile);
 
The problem appears to be that streambuf::_lock is not initialized
after being "newed" in bullet 1; thus, depending on the random values
in streambuf::_lock, the call to pthread_mutex_lock in bullet 2 hangs.
Is this a known problem?  I compile StringUtilities::intToString(int
n) as follows:

  gcc -c -DLINUX=22 -DUSE_HSREGEX -DUSE_EXPAT -I../lib/expat-lite
-fpic \
    -DSHARED_CORE -g -Wall \
    -I/projects/cmvcdev/bld/mod_cmvc/13/obj/x86_linux_2/mod_cmvc \
    -I/projects/cmvcdev/bld/mod_cmvc/13/src/mod_cmvc \
    -I/home/gdlxn/apache/apache_1.3.20-install/include \
    -I/usr/local/xml4c \
    /projects/cmvcdev/bld/mod_cmvc/13/src/mod_cmvc/StringUtilities.cpp

Should I to compile with different or additional options?

Thanks,
Geoff Alexander, Ph.D.
919/254-5216 T/L 444-5216
CMVC95 WebDAV Development
IBM Corporation
RTP, NC



reply via email to

[Prev in Thread] Current Thread [Next in Thread]