This is the mail archive of the mailing list for the Cygwin 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]

Re: Problem w/ c++,threads,static initializers

Rasmus Hahn wrote:
On Tue, Jun 10, 2003 at 09:25:43AM +0200, Thomas Pfaff wrote:

Rasmus Hahn wrote:


i am using cygwin on my Windows2000 and my c++ program segfaults
when using pthread-mutexes. In particular i am using a lot of
mutexes from within constructors of static objects. These constructors
are called at a very early time of execution of the program and do
calls of pthread_mutex_init, pthread_mutex_lock and such. Taken a glance
at the cygwin source i noticed that the static initializers (constructors
of static objects) are run _before_ some user_data->threadinterface is
initialized (look at dll_crt0_1 () in winsup/cygwin/ Isnt it possible to use thread-functions from static initializers?
BTW i am using cygwin snapshot 20030602 compiled with gcc-3.3 since the
out-of-the-box gcc from the cygwin-package is a prerelease and definitely
contains bugs that do not allow it to compile my code.

Could you provide a test case ?

  No, i cannot. As it turned out the initializers are run at least but i
  dont know if before or after cygwin-initialization. Only when run with
  gdb the program behaves differently (crash in constructors). That makes
  reproduction & location of errors a little harder.

If your program only segfaults in the debugger than the problem is a harmless IsBadWritePtr which is used to check for an already initialized mutex. You can ignore this one. Set a breakpoint at main and continue. To avoid it you can set the mutex to PTHREAD_MUTEX_INITIALIZER before you call pthread_mutex_init.


-- Unsubscribe info: Problem reports: Documentation: FAQ:

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