Re: crash if fork(2) from another thread

2008-09-30 Thread Hirokazu Yamamoto
>>I also confirmed previous code worked fine with Cygwin 1.7.
> >>But attached code hangs on Cygwin 1.7. (Actually this is what
> >>test_3_join_in_forked_from_thread is doing)
> >
> >I can duplicate this.  I'll investigate it as I have time.
>
> It should be fixed in the latest snapshot.

Thanks, I confirmed the problem was fixed on snapshot.
test_3_join_in_forked_from_thread doesn't hang now.

The test still fails, but this is because fork() copies only calling thread,
not main thread which will call fflush(stdout) on program termination.
This is allowed in POSIX, so expected behavior.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-29 Thread Christopher Faylor
On Mon, Sep 29, 2008 at 11:04:32PM -0400, Christopher Faylor wrote:
>On Mon, Sep 29, 2008 at 09:16:32PM -0400, Christopher Faylor wrote:
>>On Mon, Sep 29, 2008 at 11:42:32PM +0900, Hirokazu Yamamoto wrote:
>>>I also confirmed previous code worked fine with Cygwin 1.7.
>>>But attached code hangs on Cygwin 1.7. (Actually this is what
>>>test_3_join_in_forked_from_thread is doing)
>>
>>I can duplicate this.  I'll investigate it as I have time.
>
>It should be fixed in the latest snapshot.
>
>http://cygwin.com/snapshots.html

Sorry.  I've typed that 1257 times and I still got it wrong:

http://cygwin.com/snapshots/

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-29 Thread Christopher Faylor
On Mon, Sep 29, 2008 at 09:16:32PM -0400, Christopher Faylor wrote:
>On Mon, Sep 29, 2008 at 11:42:32PM +0900, Hirokazu Yamamoto wrote:
>>I also confirmed previous code worked fine with Cygwin 1.7.
>>But attached code hangs on Cygwin 1.7. (Actually this is what
>>test_3_join_in_forked_from_thread is doing)
>
>I can duplicate this.  I'll investigate it as I have time.

It should be fixed in the latest snapshot.

http://cygwin.com/snapshots.html

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-29 Thread Christopher Faylor
On Mon, Sep 29, 2008 at 11:42:32PM +0900, Hirokazu Yamamoto wrote:
>I also confirmed previous code worked fine with Cygwin 1.7.
>But attached code hangs on Cygwin 1.7. (Actually this is what
>test_3_join_in_forked_from_thread is doing)

I can duplicate this.  I'll investigate it as I have time.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-29 Thread Hirokazu Yamamoto
> You still didn't explain what "crash" means, that was why I pointed you
> at a web page which goes to some effort in trying to make it clear that
> you should be descriptive when reporting problems.

When I run ./main.exe

$ ./main
thread_func
parent process (child pid = 1320)
  14827 [main] main 1320 _cygtls::handle_exceptions: Error while dumping
state (
probably corrupted stack)
parent process end

I'll attach main.exe.stackdump.

> However, I did create a Vista VM with Cygwin 1.5.25 and saw that the
> code did not work.  It is a bug in 1.5.25 but it is not going to be
> fixed since we are actively pursuing 1.7 now.

OK. Thanks.


main.exe.stackdump
Description: Binary data
--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/

Re: crash if fork(2) from another thread

2008-09-29 Thread Christopher Faylor
On Sun, Sep 28, 2008 at 08:53:55PM +0900, Hirokazu Yamamoto wrote:
>cgf wrote:
>>Your test case worked fine for me with Cygwin 1.7.x.  I don't have a
>>copy of 1.5.x handy to test.
>>
>>"crash" is an imprecise term.  You need to read
>>http://cygwin.com/problems.html.
>
>I'll attach the result of "cygcheck -s -v -r > cygcheck.out"

You still didn't explain what "crash" means, that was why I pointed you
at a web page which goes to some effort in trying to make it clear that
you should be descriptive when reporting problems.

However, I did create a Vista VM with Cygwin 1.5.25 and saw that the
code did not work.  It is a bug in 1.5.25 but it is not going to be
fixed since we are actively pursuing 1.7 now.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-29 Thread Christopher Faylor
On Sun, Sep 28, 2008 at 09:50:43AM +0200, Spiro Trikaliotis wrote:
>* On Sat, Sep 27, 2008 at 11:30:13PM -0400 Christopher Faylor wrote:
>>On Sun, Sep 28, 2008 at 11:16:21AM +0900, Hirokazu Yamamoto wrote:
>>># I've post mail, but it didn't show up in
>>>http://www.nabble.com/Cygwin-f12165.html.  # Maybe it was not good to
>>>attach a file.  So try again...
>>
>>Why do people think that the fact that they sent email which never made
>>it to the list is interesting?
>
>Because they want to prevent someone complain on them that they sent
>the mail twice in case the first mail was not really lost?

If you think your email didn't make it to the list, check the archives.
Duplicate email and musings about problems sending email are both
just unneeded noise.

If checking the archives didn't occur to you prior to now, then now you
have a valuable tool at your disposal.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-29 Thread Hirokazu Yamamoto
>Your test case worked fine for me with Cygwin 1.7.x.  I don't have a
>copy of 1.5.x handy to test.

> >> I don't see any reason why this shouldn't be allowed.  You should
> >> be able to do anything you want in a child process.
> >I do not think that is true. As per
> >,
> >RATIONALE, the penultimate paragraph, it is basically undefined
behaviour.
>
> I wrote the current version of cygwin's fork.

I also confirmed previous code worked fine with Cygwin 1.7.
But attached code hangs on Cygwin 1.7. (Actually this is what
test_3_join_in_forked_from_thread is doing)


main.c
Description: Binary data
--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/

Re: crash if fork(2) from another thread

2008-09-28 Thread Christopher Faylor
On Sun, Sep 28, 2008 at 05:49:30PM +0200, V??clav Haisman wrote:
>-BEGIN PGP SIGNED MESSAGE-
>Hash: SHA256
>
>Christopher Faylor wrote, On 28.9.2008 17:25:
>> On Sun, Sep 28, 2008 at 09:32:39AM +0200, V??clav Haisman wrote:
>>> -BEGIN PGP SIGNED MESSAGE-
>>> Hash: SHA256
>>>
>>> Hirokazu Yamamoto wrote, On 28.9.2008 4:16:
 # I've post mail, but it didn't show up in
 http://www.nabble.com/Cygwin-f12165.html.
 # Maybe it was not good to attach a file. So try again...

 I'm not familiar with pthread & fork, but I think following code should not
 crash. Is this expected behavior?

 #include 
 #include 
 #include 
 #include 

 void *thread_func(void* args)
 {
 int ret;
 pid_t pid;
 pthread_t thread;

 puts("thread_func");

 pid = fork();

 assert(pid != (pid_t)-1);

 if (pid != 0) /* parent process */
 {
 int status;

 printf("parent process (child pid = %d)\n", pid);

 waitpid(pid, &status, 0);

 puts("parent process end");
 }
 else /* child process */
 {
 puts("child process"); /* crash here */
>>> I think this is not allowed in here.  You can only do async-signal-safe
>>> stuff in the child.  IO is AFAIK not in that category.  Basically, the
>>> only thing you can safely do in the child process is to call exec().
>> 
>> I don't see any reason why this shouldn't be allowed.  You should
>> be able to do anything you want in a child process.
>I do not think that is true. As per
>,
>RATIONALE, the penultimate paragraph, it is basically undefined behaviour.

I wrote the current version of cygwin's fork.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-28 Thread Václav Haisman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Christopher Faylor wrote, On 28.9.2008 17:25:
> On Sun, Sep 28, 2008 at 09:32:39AM +0200, V??clav Haisman wrote:
>> -BEGIN PGP SIGNED MESSAGE-
>> Hash: SHA256
>>
>> Hirokazu Yamamoto wrote, On 28.9.2008 4:16:
>>> # I've post mail, but it didn't show up in
>>> http://www.nabble.com/Cygwin-f12165.html.
>>> # Maybe it was not good to attach a file. So try again...
>>>
>>> I'm not familiar with pthread & fork, but I think following code should not
>>> crash. Is this expected behavior?
>>>
>>> #include 
>>> #include 
>>> #include 
>>> #include 
>>>
>>> void *thread_func(void* args)
>>> {
>>> int ret;
>>> pid_t pid;
>>> pthread_t thread;
>>>
>>> puts("thread_func");
>>>
>>> pid = fork();
>>>
>>> assert(pid != (pid_t)-1);
>>>
>>> if (pid != 0) /* parent process */
>>> {
>>> int status;
>>>
>>> printf("parent process (child pid = %d)\n", pid);
>>>
>>> waitpid(pid, &status, 0);
>>>
>>> puts("parent process end");
>>> }
>>> else /* child process */
>>> {
>>> puts("child process"); /* crash here */
>> I think this is not allowed in here.  You can only do async-signal-safe
>> stuff in the child.  IO is AFAIK not in that category.  Basically, the
>> only thing you can safely do in the child process is to call exec().
> 
> I don't see any reason why this shouldn't be allowed.  You should
> be able to do anything you want in a child process.
I do not think that is true. As per
,
RATIONALE, the penultimate paragraph, it is basically undefined behaviour.


- --
VH
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)

iFYEAREIAAYFAkjfp4oACgkQhQBMvHf/WHmFRwDgoqjd8DsvwSb8e+3BEbvYtVLK
mLXEYdMTkxauIADgsxmD6GxTDfHCyaTP41jpRkErFhTXsZ5bHcRjrg==
=hyOi
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-28 Thread Christopher Faylor
On Sun, Sep 28, 2008 at 09:32:39AM +0200, V??clav Haisman wrote:
>-BEGIN PGP SIGNED MESSAGE-
>Hash: SHA256
>
>Hirokazu Yamamoto wrote, On 28.9.2008 4:16:
>> # I've post mail, but it didn't show up in
>> http://www.nabble.com/Cygwin-f12165.html.
>> # Maybe it was not good to attach a file. So try again...
>> 
>> I'm not familiar with pthread & fork, but I think following code should not
>> crash. Is this expected behavior?
>> 
>> #include 
>> #include 
>> #include 
>> #include 
>> 
>> void *thread_func(void* args)
>> {
>> int ret;
>> pid_t pid;
>> pthread_t thread;
>> 
>> puts("thread_func");
>> 
>> pid = fork();
>> 
>> assert(pid != (pid_t)-1);
>> 
>> if (pid != 0) /* parent process */
>> {
>> int status;
>> 
>> printf("parent process (child pid = %d)\n", pid);
>> 
>> waitpid(pid, &status, 0);
>> 
>> puts("parent process end");
>> }
>> else /* child process */
>> {
>> puts("child process"); /* crash here */
>I think this is not allowed in here.  You can only do async-signal-safe
>stuff in the child.  IO is AFAIK not in that category.  Basically, the
>only thing you can safely do in the child process is to call exec().

I don't see any reason why this shouldn't be allowed.  You should
be able to do anything you want in a child process.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-28 Thread Hirokazu Yamamoto
> I think this is not allowed in here. You can only do async-signal-safe
stuff
> in the child. IO is AFAIK not in that category. Basically, the only thing
you
>  can safely do in the child process is to call exec().

Thank you for reply. I found similar info in MacOSX doc. (in CAVEATS)
http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/fork.2.html

I encountered this crash while investigating python's
trunk/Lib/test/test_threading.py
ThreadJoinOnShutdown (test_3_join_in_forked_from_thread) which hangs on
cygwin.

It's calling thread stuff and IO on child process,  maybe it's not good
practice...


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-28 Thread Hirokazu Yamamoto
> Why do people think that the fact that they sent email which never
> made it to the list is interesting?
>
> Attaching a file is fine and is the preferred way of doing this.
> Your problem is that you're using nabble.  Use the actual
> mailing list or gmane.

Yes, I'm using actual mailing list. I used nabble for confirmation. Probably
it was
not good to use zip archive as attachment. (which contained main.c and
Makefile)

> Your test case worked fine for me with Cygwin 1.7.x.  I don't have a
> copy of 1.5.x handy to test.
>
> "crash" is an imprecise term.  You need to read
> http://cygwin.com/problems.html.

I'll attach the result of "cygcheck -s -v -r > cygcheck.out"


cygcheck.out
Description: Binary data
--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/

Re: crash if fork(2) from another thread

2008-09-28 Thread Spiro Trikaliotis
Hello Christopher,

* On Sat, Sep 27, 2008 at 11:30:13PM -0400 Christopher Faylor wrote:
> On Sun, Sep 28, 2008 at 11:16:21AM +0900, Hirokazu Yamamoto wrote:
> ># I've post mail, but it didn't show up in
> >http://www.nabble.com/Cygwin-f12165.html.
> ># Maybe it was not good to attach a file. So try again...
> 
> Why do people think that the fact that they sent email which never
> made it to the list is interesting?

Because they want to prevent someone complain on them that they sent the
mail twice in case the first mail was not really lost?

Taking your answer into account, it seems either way, the poster cannot
win.

Best regards,
Spiro.

-- 
Spiro R. Trikaliotis  http://opencbm.sf.net/
http://www.trikaliotis.net/ http://www.viceteam.org/

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-28 Thread Václav Haisman
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hirokazu Yamamoto wrote, On 28.9.2008 4:16:
> # I've post mail, but it didn't show up in
> http://www.nabble.com/Cygwin-f12165.html.
> # Maybe it was not good to attach a file. So try again...
> 
> I'm not familiar with pthread & fork, but I think following code should not
> crash. Is this expected behavior?
> 
> #include 
> #include 
> #include 
> #include 
> 
> void *thread_func(void* args)
> {
> int ret;
> pid_t pid;
> pthread_t thread;
> 
> puts("thread_func");
> 
> pid = fork();
> 
> assert(pid != (pid_t)-1);
> 
> if (pid != 0) /* parent process */
> {
> int status;
> 
> printf("parent process (child pid = %d)\n", pid);
> 
> waitpid(pid, &status, 0);
> 
> puts("parent process end");
> }
> else /* child process */
> {
> puts("child process"); /* crash here */
I think this is not allowed in here. You can only do async-signal-safe stuff
in the child. IO is AFAIK not in that category. Basically, the only thing you
 can safely do in the child process is to call exec().

> }
> 
> return args;
> }
> 
> int main()
> {
> int ret;
> pthread_t thread;
> 
> ret = pthread_create(&thread, NULL, thread_func, NULL);
> assert(ret == 0);
> 
> ret = pthread_join(thread, NULL);
> assert(ret == 0);
> }
> 
> // built with "gcc main.c -o main.exe"
> 
> Thank you.

- --
VH
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (MingW32)

iFYEAREIAAYFAkjfMxcACgkQhQBMvHf/WHkrOgDgjwH6nF9WnksWQtjZDKOutx2d
Sk/irkVq2NjjzADeJOjUN3LB+WkRPYGHGubEVHVT7H5DEh2NcZtPyg==
=/9e7
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: crash if fork(2) from another thread

2008-09-27 Thread Christopher Faylor
On Sun, Sep 28, 2008 at 11:16:21AM +0900, Hirokazu Yamamoto wrote:
># I've post mail, but it didn't show up in
>http://www.nabble.com/Cygwin-f12165.html.
># Maybe it was not good to attach a file. So try again...

Why do people think that the fact that they sent email which never
made it to the list is interesting?

Attaching a file is fine and is the preferred way of doing this.
Your problem is that you're using nabble.  Use the actual
mailing list or gmane.

Your test case worked fine for me with Cygwin 1.7.x.  I don't have a
copy of 1.5.x handy to test.

"crash" is an imprecise term.  You need to read
http://cygwin.com/problems.html.

cgf

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/