Subject: G++ guru's please comment - Re: FW: pthread_create problem in Cygwin 1.1.8-2]
From: "Robert Collins" <[email-masked]>
To: <[email-masked]>
Cc: "Joost Kraaijeveld" <[email-masked]>
Date: Mon, 9 Apr 2001 01:28:08 +1000

> -------- Original Message --------
> Subject: FW: pthread_create problem in Cygwin 1.1.8-2
> Date: Sun, 8 Apr 2001 15:40:43 +0200
> From: Joost Kraaijeveld <[email-masked]>
> To: "[email-masked]'" <[email-masked]>
>
> Hi Earnie,
>
>
> I am using:
>
> Reading specs from /bin/../lib/gcc-lib/i686-pc-cygwin/2.95.3-2/specs
> gcc version 2.95.3-2 (cygwin special)
>
> Additional testing showes that if I insert a Sleep(500) in the
> threadFunction() just before the return 0 it only crahes 3-5 times of
> the 10
> runs. Also, it crashes more often after fast repeated runs of the
> program.
> It also crashes more often on faster hardware (I have tested on two
> machines, PII 400 and a PIII 700, both 256 MB RAM). Running only 1
> thread
> instead of two does not crash the program.

This smells like a threads/exception handling interaction issue of some
sort.

It crashes for me, on i=99 at the same place. It crashes _every time_
for me. Adding a sleep as you did made it crash 8/10 instead of 10/10.
Removing the return 0; from within the try {} stopped it crashing
completely.

Also, printf doesn't appear to be atomic and threadsafe (lines got
interspersed). You might be hitting something there, but I doubt it
(crashing in the wrong place).

some things to test/do:

1) It's possible it's a problem with the thread exiting code, could you
try using a pthread_exit call instead of return and report back.

2) What cygwin1.dll are you using? I'm using a custom build ~= to the
latest snapshot.
2a) Earnie - what are you testing with? (as a control point that doesn't
see the fault).

3) What's the value of ecx when it dies? Mine is
(gdb) info register
eax            0x407004 4222980
ecx            0xc0     192

3a) Earnie - if you have a few minutes, can you put a breakpoint on the
offending instruction, and report back the output o
info registers
info locals
info threads
bt in each thread?

Thanks,
Rob

>
> If I run it through GDB it shows that the crash occurs after the
"return
> 0"
> but before the closing bracket of the for loop (see the mixed output
of
> the
> debugger source window below, the offending line is marked by me with
a
> "+"). It gives a SIGSEGV for both threads.
>
>
>
> Joost
>
> 10       {
> 11          printf("%lu\n",i);
> - 0x4010ac <threadFunction(void *)+96>: add

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