unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Re: [bug #33996] 2.0.2: Crash related to ports and threads
       [not found] <20110812-094212.sv11689.31911@savannah.gnu.org>
@ 2011-08-18  9:36 ` Andy Wingo
  2011-08-18 13:42   ` rixed
  2011-08-21 13:22   ` Ludovic Courtès
  2011-11-08 18:21 ` Andy Wingo
  1 sibling, 2 replies; 7+ messages in thread
From: Andy Wingo @ 2011-08-18  9:36 UTC (permalink / raw)
  To: Cedric Cellier; +Cc: bug-guile, guile-devel

Hi Cedric,

On Fri 12 Aug 2011 09:42, Cedric Cellier <INVALID.NOREPLY@gnu.org> writes:

> (use-modules (ice-9 threads))
>
> (define (forever f)
>   (f)
>   (forever f))
>
> ; Spawn a thread that performs some writes
> (make-thread forever (lambda ()
>                        (display "write...\n")))
>
> (forever (lambda () (display "new pipe...\n")))

Oh dear, this is a nasty one.  The issue is that Guile's ports are not
threadsafe.  I hadn't thought about this one...

I am adding guile-devel to the Cc for input.  Any fix to this will be
pretty big, I think.  I think that the right fix here is probably what
Glibc does; see `info libc "Streams and Threads"` for the full details.

Basically they add a lock to each FILE*, which is probably what we
should do with our ports.  We could investigate Java's biased locking,
if that's useful.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bug #33996] 2.0.2: Crash related to ports and threads
  2011-08-18  9:36 ` [bug #33996] 2.0.2: Crash related to ports and threads Andy Wingo
@ 2011-08-18 13:42   ` rixed
  2011-08-18 17:06     ` Andy Wingo
  2011-08-21 13:22   ` Ludovic Courtès
  1 sibling, 1 reply; 7+ messages in thread
From: rixed @ 2011-08-18 13:42 UTC (permalink / raw)
  To: guile-devel

-[ Thu, Aug 18, 2011 at 11:36:37AM +0200, Andy Wingo ]----
> Oh dear, this is a nasty one.  The issue is that Guile's ports are not
> threadsafe.  I hadn't thought about this one...

Aren't they supposed to be? I though that was what scm_i_port_table_mutex
was there for.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bug #33996] 2.0.2: Crash related to ports and threads
  2011-08-18 13:42   ` rixed
@ 2011-08-18 17:06     ` Andy Wingo
  0 siblings, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2011-08-18 17:06 UTC (permalink / raw)
  To: rixed; +Cc: guile-devel

On Thu 18 Aug 2011 15:42, rixed@happyleptic.org writes:

> -[ Thu, Aug 18, 2011 at 11:36:37AM +0200, Andy Wingo ]----
>> Oh dear, this is a nasty one.  The issue is that Guile's ports are not
>> threadsafe.  I hadn't thought about this one...
>
> Aren't they supposed to be? I though that was what scm_i_port_table_mutex
> was there for.

No, that is to protect the port table, not the ports themselves.  See
fport.c:fport_write for an example of an unsafe function.  This will be
nasty to fix correctly.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bug #33996] 2.0.2: Crash related to ports and threads
  2011-08-18  9:36 ` [bug #33996] 2.0.2: Crash related to ports and threads Andy Wingo
  2011-08-18 13:42   ` rixed
@ 2011-08-21 13:22   ` Ludovic Courtès
  2011-11-09 23:16     ` Andy Wingo
  1 sibling, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2011-08-21 13:22 UTC (permalink / raw)
  To: guile-devel; +Cc: bug-guile

Hi!

Andy Wingo <wingo@pobox.com> skribis:

> Oh dear, this is a nasty one.  The issue is that Guile's ports are not
> threadsafe.  I hadn't thought about this one...
>
> I am adding guile-devel to the Cc for input.  Any fix to this will be
> pretty big, I think.  I think that the right fix here is probably what
> Glibc does; see `info libc "Streams and Threads"` for the full details.

Indeed, it would probably need per-port mutexes, making I/O primitives
thread-safe by default, and perhaps providing unlocked variants like
libc does.

Putting our fat mutexes on a diet seems like a prerequisite...

Thanks,
Ludo’.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [bug #33996] 2.0.2: Crash related to ports and threads
       [not found] <20110812-094212.sv11689.31911@savannah.gnu.org>
  2011-08-18  9:36 ` [bug #33996] 2.0.2: Crash related to ports and threads Andy Wingo
@ 2011-11-08 18:21 ` Andy Wingo
  1 sibling, 0 replies; 7+ messages in thread
From: Andy Wingo @ 2011-11-08 18:21 UTC (permalink / raw)
  To: Cedric Cellier, Andy Wingo, guile-devel

Update of bug #33996 (project guile):

                  Status:                    None => Fixed                  
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #1:

I think I have fixed this particular bug in `master'.  Others will remain. 
Unfortunately it's going to kill `write' and `display' performance in some
cases.  We can work around that in various ways.

Anyway, please send new mails to bug-guile for new bugs :-)

Andy

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?33996>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bug #33996] 2.0.2: Crash related to ports and threads
  2011-08-21 13:22   ` Ludovic Courtès
@ 2011-11-09 23:16     ` Andy Wingo
  2011-11-10  9:32       ` rixed
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Wingo @ 2011-11-09 23:16 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guile-devel

On Sun 21 Aug 2011 15:22, ludo@gnu.org (Ludovic Courtès) writes:

> Andy Wingo <wingo@pobox.com> skribis:
>
>> Oh dear, this is a nasty one.  The issue is that Guile's ports are not
>> threadsafe.  I hadn't thought about this one...
>>
>> I am adding guile-devel to the Cc for input.  Any fix to this will be
>> pretty big, I think.  I think that the right fix here is probably what
>> Glibc does; see `info libc "Streams and Threads"` for the full details.
>
> Indeed, it would probably need per-port mutexes, making I/O primitives
> thread-safe by default, and perhaps providing unlocked variants like
> libc does.

I did this in master, but something was going wrong so I stubbed it out
for the time being.  But we are almost there.

> Putting our fat mutexes on a diet seems like a prerequisite...

I would think we can use normal mutexes, no?  OTOH making dynamic-wind
and scm_dynwind_* not cons would be really nice.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [bug #33996] 2.0.2: Crash related to ports and threads
  2011-11-09 23:16     ` Andy Wingo
@ 2011-11-10  9:32       ` rixed
  0 siblings, 0 replies; 7+ messages in thread
From: rixed @ 2011-11-10  9:32 UTC (permalink / raw)
  To: guile-devel

-[ Thu, Nov 10, 2011 at 12:16:38AM +0100, Andy Wingo ]----
> > Indeed, it would probably need per-port mutexes, making I/O primitives
> > thread-safe by default, and perhaps providing unlocked variants like
> > libc does.
> 
> I did this in master, but something was going wrong so I stubbed it out
> for the time being.  But we are almost there.

Should I reopen the bug on debbug then?




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-10  9:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20110812-094212.sv11689.31911@savannah.gnu.org>
2011-08-18  9:36 ` [bug #33996] 2.0.2: Crash related to ports and threads Andy Wingo
2011-08-18 13:42   ` rixed
2011-08-18 17:06     ` Andy Wingo
2011-08-21 13:22   ` Ludovic Courtès
2011-11-09 23:16     ` Andy Wingo
2011-11-10  9:32       ` rixed
2011-11-08 18:21 ` Andy Wingo

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).