This is the mail archive of the cygwin@cygwin.com 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]

RE: G++ guru's please comment - Re: FW: pthread_create problem in Cygwin 1.1.8-2]


> -----Original Message-----
> From: Robert Collins 
> Sent: Monday, April 09, 2001 11:14 AM
> To: cygwin@cygwin.com
> Subject: RE: G++ guru's please comment - Re: FW: 
> pthread_create problem
> in Cygwin 1.1.8-2]
> 
> 
> 
> I will, once I have a good binary to compare with. I don't know what
> return 0; in a try{} should look like.
> 
> Just for fun I removed the printf, and the crash went away. It also
> never appears with only one thread running.
> 
> I've had a quick read of the asembly and will report back.
> 


I haven't got time for an exhaustive session on this during the workday.
I'll look at it more at home tonight.

It's definately not printf() trashing ecx - I have a slightly more
trivial test case below. I'd really appreciate a non-stripped working
binary of the test case below so I can track this down a little more
quickly. BTW Chris - esp looks fine to me, it's just ecx that's getting
trashed. 

If someone tries to build this, you will need a snapshot to have the
sched_yield() function. The bug isn't in the pthread code AFAICT - Joost
is on 1.1.8, and I'm on my new code, and we both have the same symptoms.

>From what I can see so far the exception is related to the thread
exiting within the try {} block after the thread function has lost the
processor to another instance of the same function. sched_yield() simply
forces that to occur.

(going out on a limb) This may be something solvable by building gcc
with pthread exception handling as Mumit suggested. 

Rob

Build with this makefile:
=== Makefile ===
all: AlibTest.exe

Main.o: main.cpp
        g++ -c -mthreads -g -O0 -Wall -o"Main.o" main.cpp

AlibTest.exe: Main.o
        g++ -mthreads  -o./ALibTest.exe Main.o

=== main.cpp ===
#include <pthread.h>
#include <sched.h>
#include <windows.h>
#include <stdio.h>

void *threadFunction(void * arg)
{
try
    {
        sched_yield();
        return 0;
    }
    catch(...)
    {
    }
    return 0;
}

int main()
{
  pthread_t t1;
  pthread_t t2;
  pthread_create(&t1, NULL, threadFunction, NULL);
  pthread_create(&t2, NULL, threadFunction, NULL);
  Sleep(3000);
  return 0;
}

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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