caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: John Carr <jfc@mit.edu>
Cc: "Richard W.M. Jones" <rich@annexia.org>, Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] Interfacing with C: bad practice
Date: Tue, 16 Aug 2011 17:14:22 +0100	[thread overview]
Message-ID: <CAOg1smCMXGMBDmvg=raW_D=i739rr9GSbbZowfrhKvFPaNz0GQ@mail.gmail.com> (raw)
In-Reply-To: <201108161606.p7GG6wR9029895@outgoing.mit.edu>

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

On Tue, Aug 16, 2011 at 5:06 PM, John Carr <jfc@mit.edu> wrote:

>
> Richard W.M. Jones <rich@annexia.org> wrote:
>
> > On Tue, Aug 16, 2011 at 11:37:03AM +0400, Dmitry Bely wrote:
> > > C compiler first puts "list" pointer on stack and then calls
> > > caml_copy_string(*s), potentially invalidating "list". Of course, the
> > > stack copy of "list" is not registered as a global root so wrp_ml_cons
> > > gets an invalid value.
> >
> > 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.
>

Maybe looking at the assembly output would help. If you can post the output
with gcc -S flag.

Cheers;
Wojciech

The call
>
>   f(g(), x)
>
> can behave as either
>
>  temp1 = g()
>  temp2 = x
>  f(temp1, temp2)
>
> or
>
>  temp1 = x
>  temp2 = g()
>  f(temp2, temp1)
>
> The order does not need to be deterministic.
>
> If the call to g() changes x, the second order results in the
> function f() receiving the "wrong" value.
>
>    --John Carr (jfc@mit.edu)
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>

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

  reply	other threads:[~2011-08-16 16:14 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
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 [this message]
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='CAOg1smCMXGMBDmvg=raW_D=i739rr9GSbbZowfrhKvFPaNz0GQ@mail.gmail.com' \
    --to=wojciech.meyer@googlemail.com \
    --cc=caml-list@inria.fr \
    --cc=jfc@mit.edu \
    --cc=rich@annexia.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).