caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ville-Pertti Keinonen <will@exomi.com>
To: Anastasia Gornostaeva <ermine@ermine.pp.ru>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] timer
Date: Tue, 01 Feb 2005 16:30:55 +0200	[thread overview]
Message-ID: <1107268256.669.87.camel@localhost> (raw)
In-Reply-To: <20050201122213.GA82702@ermine.home>

On Tue, 2005-02-01 at 15:22 +0300, Anastasia Gornostaeva wrote:

> I have different FreeBSDs, 5.2rc2 and 5.3-release. 
> On 5.2rc2 using libc_r is by default but just now I use libmap.conf only for 
> ocaml-compiled programs to use pthreads. 

Does it work correctly for you when using libpthread on 5.2rc2 (it
might've still been called libkse)?

Does it work correctly with 5.3-release?  (I'd definitely expect it to.)

> I still dont believe it is only freebsd related problem if i use 
> freebsd 5.2rc2 for long time and with wide range of sowtware without 
> problems. For example, on my machine there is running Zope based on python 2.1,
> that is linked against libc_r. Well, i dont know if it uses signals ...

libc_r works most of the time, including signals, but OCaml makes a
particular misbehavior easy to trigger.

This is getting somewhat off-topic, but it still relates to getting
OCaml programs to work correctly, so...

Based on a quick look at the libc_r sources, it seems that what actually
happens is when entering a signal handler, the signal being delivered is
masked (as is sa_mask), and when leaving the handler, the original
signal mask is restored...as long as it hasn't been changed by the
signal handler.  OCaml always modifies the signal mask inside the
handler.

This seems like a misreading of the standard.  According to SUS3:

    When a signal is caught by a signal-catching function installed
    by sigaction(), a new signal mask is calculated and installed for
    the duration of the signal-catching function (or until a call to
    either sigprocmask() or sigsuspend() is made).

    ...

    If and when the user's signal handler returns normally, the
    original signal mask is restored.

Apparently the author of libc_r interpreted the "or until a call to
either sigprocmask() or sigsuspend() is made" to also cancel the
restoration of the original mask.

If you must use libc_r, the following modification might fix the problem
(disclaimer - I haven't tested it):

--- uthread_sig.c.orig  Wed Dec  3 08:54:40 2003
+++ uthread_sig.c       Tue Feb  1 15:52:53 2005
@@ -1112,12 +1112,14 @@
     struct pthread_signal_frame *psf)
 {
        memcpy(&thread->ctx, &psf->ctx, sizeof(thread->ctx));
+#if 0
        /*
         * Only restore the signal mask if it hasn't been changed
         * by the application during invocation of the signal handler:
         */
        if (thread->sigmask_seqno == psf->saved_state.psd_sigmask_seqno)
+#endif
                thread->sigmask = psf->saved_state.psd_sigmask;
        thread->curframe = psf->saved_state.psd_curframe;
        thread->wakeup_time = psf->saved_state.psd_wakeup_time;
        thread->data = psf->saved_state.psd_wait_data;



      reply	other threads:[~2005-02-01 14:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-03  1:58 timer Anastasia Gornostaeva
2005-01-04  1:11 ` [Caml-list] timer SooHyoung Oh
2005-01-31 19:33   ` Anastasia Gornostaeva
2005-01-31 21:21     ` Alain Frisch
2005-02-01  7:50     ` Ville-Pertti Keinonen
2005-02-01 12:22       ` Anastasia Gornostaeva
2005-02-01 14:30         ` Ville-Pertti Keinonen [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

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

  git send-email \
    --in-reply-to=1107268256.669.87.camel@localhost \
    --to=will@exomi.com \
    --cc=caml-list@inria.fr \
    --cc=ermine@ermine.pp.ru \
    /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 NNTP newsgroup(s).