This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


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

Re: Seg-fault before main() with pthread


> Any idea what's going wrong here?

Without actually testing anything, it looks like IO locks don't really
work, right now. In genops.c, we find

void
_IO_init (fp, flags)
     _IO_FILE *fp;
     int flags;
{
  ...
#ifdef _IO_MTSAFE_IO
  _IO_lock_init (*fp->_lock);
#endif
}

so the expectation clearly is that the new file has a member _lock
pointing to a valid _IO_lock_t (_lock itself is of type _IO_LOCK_T).

Now, this is called from

  __basic_file::__basic_file() 
  {
    _IO_init(this, 0);
    _IO_file_init(this); 
  }
  
where

  class __basic_file: public __c_file_type{...

__c_file_type is a POD, with no constructor, so _lock does not get
initialized. What *should* happen, imho, is

  class __basic_file: public __c_file_type{
    _IO_lock_t __cxx_lock;

  __basic_file::__basic_file() 
#ifdef _IO_MTSAFE_IO
    : _lock(&__cxx_lock)
#endif
  {
    _IO_init(this, 0);
    _IO_file_init(this); 
  }

Hope this helps,
Martin

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