unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Derek Upham <sand@blarg.net>
Cc: 26858@debbugs.gnu.org, guile-devel@gnu.org
Subject: bug#26858: Cygwin port of Guile 2.2
Date: Mon, 15 May 2017 22:06:27 +0200	[thread overview]
Message-ID: <87ziedopfg.fsf__41248.2204068967$1494878835$gmane$org@pobox.com> (raw)
In-Reply-To: <878tm26u4t.fsf@priss.frightenedpiglet.com> (Derek Upham's message of "Fri, 12 May 2017 07:13:06 -0700")

Greets,

On Fri 12 May 2017 16:13, Derek Upham <sand@blarg.net> writes:

> Andy Wingo <wingo@pobox.com> writes:
>
>> scm_join_thread isn't actually implemented in terms of
>> scm_i_pthread_join any more.  Probably that's what's going wrong here --
>> and probably that should be fixed to ensure that we actually join the
>> thread.  (Otherwise it would be a memory leak too AFAIU.)  Bcc'ing
>> bug-guile to create a bug for that.
>
> I noticed that scm_join_thread was calling back into Scheme-land.  Are these statements all correct?
>
> - We are using call-with-new-thread underneath the hood.

Underneath the hood of what? :)

> - call-with-new-thread is documented to return a Scheme object from a
> thunk/handler.  Any underlying pthreads should be implementation
> details.

Correct.  In practice call-with-new-thread will create a pthread but I
can imagine circumstances in which it might (in the future) spawn an
auxiliary pthread for some reason, and I wouldn't want to rule that out.

> - The spawned thread sends the Scheme object to the condition variable
> as soon as the user thunk exits.  Any number of operations can happen
> afterwards; the thread is still running in Scheme-land at this point,
> in call-with-new-thread’s wrapping thunk.
> - join-thread waits on the condition variable only.

These are implementation details.  They are correct but probably the
implementation should change to do the scm_i_pthread_join and we should
guarantee that after the join, the thread is really dead.  This is bug
26858.

> So at the end of join-thread we need to add a call to
> scm_i_pthread_join (which we implement in threads.c) to ensure that
> the pthread is completely gone before that join-thread returns.  Is
> that accurate?

Well... yes, but we have to ensure that we call scm_i_pthread_join at
most once.  I think calling pthread_join twice on a thread is
undefined.  So there are some gnarlies here.  Need to fix this.

> Unfortunately, I think the GC threads are going to end up being
> immovable objects in the path to full process-form support.

You can disable marker threads with the GC_MARKERS environment variable,
and the finalization thread should come and go as needed.  Probably this
is not a blocker from your POV.  Signal handling is probably the most
serious issue; perhaps we can avoid the thread somehow, since we handle
signals asynchronously anyway..

Andy





      parent reply	other threads:[~2017-05-15 20:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <874ly49l54.fsf@joshua.spikycactus.dnsalias.com>
     [not found] ` <87lgr38jzd.fsf@pobox.com>
     [not found]   ` <87pogft8c2.fsf@priss.frightenedpiglet.com>
     [not found]     ` <878tmz7945.fsf@pobox.com>
     [not found]       ` <87ziffcbwg.fsf@priss.frightenedpiglet.com>
     [not found]         ` <87ziew4836.fsf@priss.frightenedpiglet.com>
     [not found]           ` <8760hjt5k0.fsf@pobox.com>
     [not found]             ` <87r306d3vx.fsf@priss.frightenedpiglet.com>
     [not found]               ` <87lgqes375.fsf@pobox.com>
     [not found]                 ` <87efw681hv.fsf@priss.frightenedpiglet.com>
     [not found]                   ` <87shkdrgpz.fsf@pobox.com>
2017-05-09 19:26                     ` bug#26858: Cygwin port of Guile 2.2 Glenn Morris
     [not found]                     ` <878tm26u4t.fsf@priss.frightenedpiglet.com>
2017-05-15 20:06                       ` Andy Wingo [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='87ziedopfg.fsf__41248.2204068967$1494878835$gmane$org@pobox.com' \
    --to=wingo@pobox.com \
    --cc=26858@debbugs.gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=sand@blarg.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).