This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Re: Seg-fault before main() with pthread
- To: pb at schenk dot isar dot de
- Subject: Re: Seg-fault before main() with pthread
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Tue, 23 Nov 1999 21:49:15 +0100
- CC: libstdc++ at sourceware dot cygnus dot com
- References: <Pine.LNX.4.10.9911230937580.1053-100000@pcpb.rt.schenk>
> 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