unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
@ 2013-05-30 11:06 Panicz Maciej Godek
  2013-06-04 12:49 ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Panicz Maciej Godek @ 2013-05-30 11:06 UTC (permalink / raw)
  To: 14511

[-- Attachment #1: Type: text/plain, Size: 416 bytes --]

Hi,
I've noticed that when a thread is asleep and (gc) or scm_gc() is called,
it gets awoken. It can be demonstrated with the following example:

> (call-with-new-thread
    (lambda()
      (while #t
        (display "tick!\n")
        (sleep 5)))) ;; <= this is 5 seconds!

> (gc)
tick! ;; this happens immediately after each call to gc!

This behaviour is both unexpected and undocumented, so I consider it a bug.

[-- Attachment #2: Type: text/html, Size: 696 bytes --]

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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-05-30 11:06 bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread Panicz Maciej Godek
@ 2013-06-04 12:49 ` Ludovic Courtès
  2013-06-04 13:11   ` Panicz Maciej Godek
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2013-06-04 12:49 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: 14511

Panicz Maciej Godek <godek.maciek@gmail.com> skribis:

> I've noticed that when a thread is asleep and (gc) or scm_gc() is called,
> it gets awoken. It can be demonstrated with the following example:
>
>> (call-with-new-thread
>     (lambda()
>       (while #t
>         (display "tick!\n")
>         (sleep 5)))) ;; <= this is 5 seconds!
>
>> (gc)
> tick! ;; this happens immediately after each call to gc!

I can’t reproduce it with current ‘stable-2.0’ and ‘master’, on
x86_64-linux-gnu, with libgc 7.2alpha6 (which is ancient).

Could you provide more info about your system and dependency versions?

TIA,
Ludo’.





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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-06-04 12:49 ` Ludovic Courtès
@ 2013-06-04 13:11   ` Panicz Maciej Godek
  2013-06-04 13:36     ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Panicz Maciej Godek @ 2013-06-04 13:11 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 14511

[-- Attachment #1: Type: text/plain, Size: 1624 bytes --]

2013/6/4 Ludovic Courtès <ludo@gnu.org>

> [...]
> I can’t reproduce it with current ‘stable-2.0’ and ‘master’, on
> x86_64-linux-gnu, with libgc 7.2alpha6 (which is ancient).
>
> Could you provide more info about your system and dependency versions


i am using the version from ubuntu 12.04 repository

$ guile --version | grep guile
guile (GNU Guile) 2.0.5-deb+1-1

$ uname -a
Linux godek-ThinkPad-X61s 3.2.0-45-generic #70-Ubuntu SMP Wed May 29
20:12:06 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

$ ldd /usr/bin/guile
linux-vdso.so.1 =>  (0x00007fff191dc000)
libguile-2.0.so.22 => /usr/lib/libguile-2.0.so.22 (0x00007f135393d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007f1353720000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1353360000)
libgc.so.1 => /usr/lib/libgc.so.1 (0x00007f135310c000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f1352f04000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f1352cfb000)
libunistring.so.0 => /usr/lib/x86_64-linux-gnu/libunistring.so.0
(0x00007f13529e6000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f1352778000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007f135256d000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f1352334000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1352038000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1353cdd000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1351e33000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1351c1d000)

If you need more information, let me know.

[-- Attachment #2: Type: text/html, Size: 3636 bytes --]

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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-06-04 13:11   ` Panicz Maciej Godek
@ 2013-06-04 13:36     ` Ludovic Courtès
  2013-06-04 14:38       ` Panicz Maciej Godek
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2013-06-04 13:36 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: 14511

Panicz Maciej Godek <godek.maciek@gmail.com> skribis:

> 2013/6/4 Ludovic Courtès <ludo@gnu.org>
>
>> [...]
>> I can’t reproduce it with current ‘stable-2.0’ and ‘master’, on
>> x86_64-linux-gnu, with libgc 7.2alpha6 (which is ancient).
>>
>> Could you provide more info about your system and dependency versions
>
>
> i am using the version from ubuntu 12.04 repository
>
> $ guile --version | grep guile
> guile (GNU Guile) 2.0.5-deb+1-1

And what version of libgc (the garbage collector)?

Could you check whether the problem still occurs with Guile 2.0.9?

TIA,
Ludo’.





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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-06-04 13:36     ` Ludovic Courtès
@ 2013-06-04 14:38       ` Panicz Maciej Godek
  2013-06-05  8:03         ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Panicz Maciej Godek @ 2013-06-04 14:38 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 14511

[-- Attachment #1: Type: text/plain, Size: 1212 bytes --]

2013/6/4 Ludovic Courtès <ludo@gnu.org>

> Panicz Maciej Godek <godek.maciek@gmail.com> skribis:
>
> > 2013/6/4 Ludovic Courtès <ludo@gnu.org>
> >
> >> [...]
> >> I can’t reproduce it with current ‘stable-2.0’ and ‘master’, on
> >> x86_64-linux-gnu, with libgc 7.2alpha6 (which is ancient).
> >>
> >> Could you provide more info about your system and dependency versions
> >
> >
> > i am using the version from ubuntu 12.04 repository
> >
> > $ guile --version | grep guile
> > guile (GNU Guile) 2.0.5-deb+1-1
>
> And what version of libgc (the garbage collector)?
>
>
I don't exactly know how to check it. Dpkg reports the following:

$ dpkg -s libgc1c2
Package: libgc1c2
Status: install ok installed
Priority: standard
Section: libs
Installed-Size: 254
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: libgc
Version: 1:7.1-8ubuntu0.12.04.1
Replaces: libgc1
Depends: libc6 (>= 2.14), libgcc1 (>= 1:4.1.1)
Conflicts: libgc1
Description: conservative garbage collector for C and C++

Could you check whether the problem still occurs with Guile 2.0.9?
>
>
 It does (at least when linked against the same garbage collector)

[-- Attachment #2: Type: text/html, Size: 2291 bytes --]

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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-06-04 14:38       ` Panicz Maciej Godek
@ 2013-06-05  8:03         ` Ludovic Courtès
  2013-06-05 11:12           ` Panicz Maciej Godek
  0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2013-06-05  8:03 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: 14511

Panicz Maciej Godek <godek.maciek@gmail.com> skribis:

> 2013/6/4 Ludovic Courtès <ludo@gnu.org>
>
>> Panicz Maciej Godek <godek.maciek@gmail.com> skribis:
>>
>> > 2013/6/4 Ludovic Courtès <ludo@gnu.org>
>> >
>> >> [...]
>> >> I can’t reproduce it with current ‘stable-2.0’ and ‘master’, on
>> >> x86_64-linux-gnu, with libgc 7.2alpha6 (which is ancient).
>> >>
>> >> Could you provide more info about your system and dependency versions
>> >
>> >
>> > i am using the version from ubuntu 12.04 repository
>> >
>> > $ guile --version | grep guile
>> > guile (GNU Guile) 2.0.5-deb+1-1
>>
>> And what version of libgc (the garbage collector)?
>>

[...]

> Version: 1:7.1-8ubuntu0.12.04.1

[...]

>> Could you check whether the problem still occurs with Guile 2.0.9?
>>
>  It does (at least when linked against the same garbage collector)

The documentation of ‘sleep’ is:

  - Scheme Procedure: sleep i
       Wait for the given number of seconds (an integer) or until a signal
       arrives.  The return value is zero if the time elapses or the
       number of seconds remaining otherwise.

I’m pretty sure that if you check its return value, you’ll notice that
it behaves as documented.  Can you confirm?

What happens here is that libgc uses signals for stop-the-world
collections, and (gc) certainly does with the libgc version you’re
using.

‘sleep’ calls select(2), which in your case presumably returns
prematurely with EINTR.  You should be able to confirm this hypothesis
by running Guile with:

  strace -f -e select guile

(Note that the problem doesn’t occur with libgc 7.2, presumably because
it uses a different strategy.)

Thanks,
Ludo’.





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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-06-05  8:03         ` Ludovic Courtès
@ 2013-06-05 11:12           ` Panicz Maciej Godek
  2013-06-05 11:38             ` Ludovic Courtès
  0 siblings, 1 reply; 8+ messages in thread
From: Panicz Maciej Godek @ 2013-06-05 11:12 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 14511

[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]

2013/6/5 Ludovic Courtès <ludo@gnu.org>

> [...]
>
> > Version: 1:7.1-8ubuntu0.12.04.1
>
> [...]
>
> >> Could you check whether the problem still occurs with Guile 2.0.9?
> >>
> >  It does (at least when linked against the same garbage collector)
>
> The documentation of ‘sleep’ is:
>
>   - Scheme Procedure: sleep i
>        Wait for the given number of seconds (an integer) or until a signal
>        arrives.  The return value is zero if the time elapses or the
>        number of seconds remaining otherwise.
>
> I’m pretty sure that if you check its return value, you’ll notice that
> it behaves as documented.  Can you confirm?
>
> What happens here is that libgc uses signals for stop-the-world
> collections, and (gc) certainly does with the libgc version you’re
> using.
>
> ‘sleep’ calls select(2), which in your case presumably returns
> prematurely with EINTR.  You should be able to confirm this hypothesis
> by running Guile with:
>
>   strace -f -e select guile
>
> (Note that the problem doesn’t occur with libgc 7.2, presumably because
> it uses a different strategy.)
>
>
Yes, you're right. Sleep does behave as documented, but I didn't expect
that gc might raise a signal.
Sorry for the confusion.
However, I replaced the libgc.so with a newly compiled one (7.2d) and
nothing changed, so I guess that the reason might be more casual

Thanks a lot

[-- Attachment #2: Type: text/html, Size: 1989 bytes --]

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

* bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread
  2013-06-05 11:12           ` Panicz Maciej Godek
@ 2013-06-05 11:38             ` Ludovic Courtès
  0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2013-06-05 11:38 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: 14511-done

Panicz Maciej Godek <godek.maciek@gmail.com> skribis:

> Yes, you're right. Sleep does behave as documented, but I didn't expect
> that gc might raise a signal.
> Sorry for the confusion.

No problem.

> However, I replaced the libgc.so with a newly compiled one (7.2d) and
> nothing changed, so I guess that the reason might be more casual

Hmm yes.  Well, libgc can definitely resort to signals, but how it
chooses to do it is really an implementation detail, so I don’t know why
we’re seeing a difference here.

Ludo’.





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

end of thread, other threads:[~2013-06-05 11:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-30 11:06 bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another thread Panicz Maciej Godek
2013-06-04 12:49 ` Ludovic Courtès
2013-06-04 13:11   ` Panicz Maciej Godek
2013-06-04 13:36     ` Ludovic Courtès
2013-06-04 14:38       ` Panicz Maciej Godek
2013-06-05  8:03         ` Ludovic Courtès
2013-06-05 11:12           ` Panicz Maciej Godek
2013-06-05 11:38             ` Ludovic Courtès

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