GNU bug report logs - #14511
Unexpected behaviour of scm_gc+sleep/usleep in another thread

Previous Next

Package: guile;

Reported by: Panicz Maciej Godek <godek.maciek <at> gmail.com>

Date: Thu, 30 May 2013 11:23:02 UTC

Severity: normal

Done: ludo <at> gnu.org (Ludovic Courtès)

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14511 in the body.
You can then email your comments to 14511 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Thu, 30 May 2013 11:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Panicz Maciej Godek <godek.maciek <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Thu, 30 May 2013 11:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Panicz Maciej Godek <godek.maciek <at> gmail.com>
To: bug-guile <at> gnu.org
Subject: Unexpected behaviour of scm_gc+sleep/usleep in another thread
Date: Thu, 30 May 2013 13:06:51 +0200
[Message part 1 (text/plain, inline)]
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.
[Message part 2 (text/html, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Tue, 04 Jun 2013 12:52:02 GMT) Full text and rfc822 format available.

Message #8 received at 14511 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Panicz Maciej Godek <godek.maciek <at> gmail.com>
Cc: 14511 <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Tue, 04 Jun 2013 14:49:19 +0200
Panicz Maciej Godek <godek.maciek <at> 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’.




Information forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Tue, 04 Jun 2013 13:14:02 GMT) Full text and rfc822 format available.

Message #11 received at 14511 <at> debbugs.gnu.org (full text, mbox):

From: Panicz Maciej Godek <godek.maciek <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 14511 <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Tue, 4 Jun 2013 15:11:36 +0200
[Message part 1 (text/plain, inline)]
2013/6/4 Ludovic Courtès <ludo <at> 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.
[Message part 2 (text/html, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Tue, 04 Jun 2013 13:39:02 GMT) Full text and rfc822 format available.

Message #14 received at 14511 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Panicz Maciej Godek <godek.maciek <at> gmail.com>
Cc: 14511 <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Tue, 04 Jun 2013 15:36:30 +0200
Panicz Maciej Godek <godek.maciek <at> gmail.com> skribis:

> 2013/6/4 Ludovic Courtès <ludo <at> 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’.




Information forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Tue, 04 Jun 2013 14:41:02 GMT) Full text and rfc822 format available.

Message #17 received at 14511 <at> debbugs.gnu.org (full text, mbox):

From: Panicz Maciej Godek <godek.maciek <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 14511 <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Tue, 4 Jun 2013 16:38:39 +0200
[Message part 1 (text/plain, inline)]
2013/6/4 Ludovic Courtès <ludo <at> gnu.org>

> Panicz Maciej Godek <godek.maciek <at> gmail.com> skribis:
>
> > 2013/6/4 Ludovic Courtès <ludo <at> 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 <at> 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)
[Message part 2 (text/html, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Wed, 05 Jun 2013 08:06:02 GMT) Full text and rfc822 format available.

Message #20 received at 14511 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Panicz Maciej Godek <godek.maciek <at> gmail.com>
Cc: 14511 <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Wed, 05 Jun 2013 10:03:09 +0200
Panicz Maciej Godek <godek.maciek <at> gmail.com> skribis:

> 2013/6/4 Ludovic Courtès <ludo <at> gnu.org>
>
>> Panicz Maciej Godek <godek.maciek <at> gmail.com> skribis:
>>
>> > 2013/6/4 Ludovic Courtès <ludo <at> 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’.




Information forwarded to bug-guile <at> gnu.org:
bug#14511; Package guile. (Wed, 05 Jun 2013 11:15:01 GMT) Full text and rfc822 format available.

Message #23 received at 14511 <at> debbugs.gnu.org (full text, mbox):

From: Panicz Maciej Godek <godek.maciek <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 14511 <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Wed, 5 Jun 2013 13:12:38 +0200
[Message part 1 (text/plain, inline)]
2013/6/5 Ludovic Courtès <ludo <at> 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
[Message part 2 (text/html, inline)]

Reply sent to ludo <at> gnu.org (Ludovic Courtès):
You have taken responsibility. (Wed, 05 Jun 2013 11:41:02 GMT) Full text and rfc822 format available.

Notification sent to Panicz Maciej Godek <godek.maciek <at> gmail.com>:
bug acknowledged by developer. (Wed, 05 Jun 2013 11:41:02 GMT) Full text and rfc822 format available.

Message #28 received at 14511-done <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Panicz Maciej Godek <godek.maciek <at> gmail.com>
Cc: 14511-done <at> debbugs.gnu.org
Subject: Re: bug#14511: Unexpected behaviour of scm_gc+sleep/usleep in another
	thread
Date: Wed, 05 Jun 2013 13:38:44 +0200
Panicz Maciej Godek <godek.maciek <at> 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’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 04 Jul 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 48 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.