caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: malc <av1474@comtv.ru>
To: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] caml_alloc + 64 bits - caml_alloc.h
Date: Tue, 13 Jan 2009 12:37:36 +0300 (MSK)	[thread overview]
Message-ID: <Pine.LNX.4.64.0901131232550.2161@linmac.oyster.ru> (raw)
In-Reply-To: <20090113045116.GA646@yquem.inria.fr>

On Tue, 13 Jan 2009, Daniel de Rauglaudre wrote:

> Hi everybody,
>
> Possibly useful information. Is it already known?
>
> When using calls to "caml_alloc" in a 64 bits architecture without
> having included "caml/alloc.h", it raises "Segmentation fault" at
> execution time.
>
> Notice that I got no warning at compilation time for using caml_alloc
> without a definition stub.
>
> In 32 bits architecture, I never had any problem with that.

caml_alloc returns value which is typedefed to intnat which in turn
is long which is 64bit on LP64 architectures (for all practical
intents and purposes anything that is not Win64), when prototype
for caml_alloc is missing it is assumed to be `int caml_alloc();'
assigning the return value of this call to value will sign extend
it with devastating results (upper 32bit lost forever)

> Morality:
>   Don't forget to #include "caml/alloc.h" in your C programs
>   if you alloc OCaml things!

Moraility is to follow relevant standard actually..

P.S. This whole value->intnat->long makes me wonder how OCaml is
      ever supposed to work on LLP64...

-- 
mailto:av1474@comtv.ru


  parent reply	other threads:[~2009-01-13  9:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-13  4:51 Daniel de Rauglaudre
2009-01-13  4:58 ` [Caml-list] " Erik de Castro Lopo
2009-01-13  5:15   ` Daniel de Rauglaudre
2009-01-13  9:37 ` malc [this message]
2009-01-13 10:26   ` Olivier Andrieu

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=Pine.LNX.4.64.0901131232550.2161@linmac.oyster.ru \
    --to=av1474@comtv.ru \
    --cc=caml-list@inria.fr \
    --cc=daniel.de_rauglaudre@inria.fr \
    /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).