caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Richard W.M. Jones" <rich@annexia.org>
To: rixed@happyleptic.org
Cc: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Interfacing with C: bad practice
Date: Tue, 16 Aug 2011 17:10:42 +0100	[thread overview]
Message-ID: <20110816161042.GA31932@annexia.org> (raw)
In-Reply-To: <20110816155137.GA18365@ccellier.rd.securactive.lan>

On Tue, Aug 16, 2011 at 05:51:38PM +0200, rixed@happyleptic.org wrote:
> -[ Tue, Aug 16, 2011 at 04:25:50PM +0100, Richard W.M. Jones ]----
> > I think this must be a bug in your C compiler.  The address of list is
> > stashed in the roots struct, so the C compiler should know that list
> > can be changed by the call to caml_copy_string.
> 
> Are you certain that the C abstract machine allow for any value stored
> within the frameset of a function to be changed by a function call when
> the address of the variable at hand is not passed to this function? And
> mandate the C compiler to handle this scenario? In other words, mandate
> the C compiler to reload from the stack all values between any function
> call?
> 
> I don't think so ; or more likely I have not understood your view on
> this matter?

Well it would certainly help if we had a piece of runnable code to
look at.  The code supplied in the original email contains an infinite
loop.

Nevertheless, the C compiler isn't allowed to just push 'list' blindly
onto the stack and assume it doesn't change across the call to
'caml_copy_string'.  Calls in C are sequence points, and the compiler
cannot possibly assume that 'list' won't change, because the address
of 'list' has been taken *and* is directly reachable in two steps from
caml__local_roots, which is a global variable.

If the compiler is doing this (and we don't really have proof of that
because there is no runnable code nor is a compiler + version
specified), then the compiler has a bug.

Rich.

-- 
Richard Jones
Red Hat

  parent reply	other threads:[~2011-08-16 16:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-16  7:37 Dmitry Bely
2011-08-16  8:04 ` Török Edwin
2011-08-16  8:25   ` Dmitry Bely
2011-08-16  8:43     ` Török Edwin
2011-08-16  9:46       ` rixed
2011-08-16  9:53         ` Dmitry Bely
2011-08-16 10:17           ` Török Edwin
2011-08-16 11:04             ` rixed
     [not found] ` <20110816.105738.246515733851238101.Christophe.Troestler@umons.ac.be>
2011-08-16  9:21   ` Dmitry Bely
2011-08-16 10:39     ` Mauricio Fernandez
2011-08-16 14:27       ` John Carr
2011-08-16 12:28 ` [Caml-list] " Dmitry Bely
2011-08-16 15:25 ` [Caml-list] " Richard W.M. Jones
2011-08-16 15:51   ` rixed
2011-08-16 16:00     ` Will M. Farr
2011-08-16 16:10     ` Richard W.M. Jones [this message]
2011-08-16 16:17       ` Richard W.M. Jones
2011-08-16 16:18       ` Dmitry Bely
2011-08-16 16:22         ` Richard W.M. Jones
2011-08-16 16:27           ` Richard W.M. Jones
2011-08-16 16:30             ` malc
2011-08-16 16:34             ` Török Edwin
2011-08-16 16:47               ` Richard W.M. Jones
2011-08-16 16:55               ` [Caml-list] " Jeffrey Scofield
2011-08-16 17:08                 ` Will M. Farr
2011-08-16 19:46                 ` Gerd Stolpmann
2011-08-16 20:18                   ` Jeffrey Scofield
2011-08-16 17:08       ` [Caml-list] " rixed
2011-08-16 16:06   ` John Carr
2011-08-16 16:14     ` Wojciech Meyer
2011-08-16 16:13   ` Dmitry Bely

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=20110816161042.GA31932@annexia.org \
    --to=rich@annexia.org \
    --cc=caml-list@inria.fr \
    --cc=rixed@happyleptic.org \
    /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).