From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Unsafe features
Date: Sun, 04 Sep 2005 03:58:35 +0200 (CEST) [thread overview]
Message-ID: <20050904.035835.07647783.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <87slwmjkdx.fsf@mid.deneb.enyo.de>
From: Florian Weimer <fw@deneb.enyo.de>
> I gave it a try and got:
>
> # let x : int = Obj.magic "x";;
> val x : int = 67381588
> # x;;
> - : int = 67381588
> #
>
> The "67381588" is just half the integral value of a heap address
> (because of the tag bit, I presume). And looking at the ltrace
> output, it seems that it is indeed close to the storage area of that
> string.
You are right indeed. Here is another way to see that this only
changes the apparent type of the underlying value:
# let x : int = Obj.magic (String.create 3);;
val x : int = 67389852
# Gc.full_major();;
- : unit = ()
# x;;
- : int = 68129330
Oops, here is an integer that changes with the GC...
Worse:
# let y = x+13;;
val y : int = 67407805
# Gc.full_major();;
Segmentation fault
Jacques
next prev parent reply other threads:[~2005-09-04 1:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-02 12:02 Florian Weimer
2005-09-03 9:24 ` [Caml-list] " Damien Bobillot
2005-09-03 9:40 ` Florian Weimer
2005-09-03 11:19 ` Jon Harrop
2005-09-03 12:07 ` yoann padioleau
2005-09-03 14:28 ` Florian Weimer
2005-09-03 14:35 ` yoann padioleau
2005-09-03 14:47 ` Florian Weimer
2005-09-03 14:51 ` Florian Weimer
2005-09-03 14:55 ` yoann padioleau
2005-09-04 1:58 ` Jacques Garrigue [this message]
2005-09-03 9:29 ` Erik de Castro Lopo
2005-11-29 18:46 ` Integral solutions of rational linear equations Thomas Gazagnaire
2005-11-30 8:32 ` [Caml-list] " Sebastian Egner
2005-11-30 8:49 ` Christophe Raffalli
2005-11-30 9:06 ` Christophe Raffalli
2005-11-30 9:08 ` Christophe Raffalli
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=20050904.035835.07647783.garrigue@math.nagoya-u.ac.jp \
--to=garrigue@math.nagoya-u.ac.jp \
--cc=caml-list@yquem.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