From: Eric Hielscher <hielscher@gmail.com>
To: caml-list@yquem.inria.fr
Subject: Bigarrays alloc'ed from C not surviving function return
Date: Mon, 15 Feb 2010 15:47:44 -0500 [thread overview]
Message-ID: <d550840e1002151247x76bbdacbp589df7c40e24839e@mail.gmail.com> (raw)
Hi all,
I'm using the C interface to glue OCaml to another language's runtime
(don't ask). For the most part everything seems to be working for me,
except I'm getting a strange problem when it comes to bigarrays which
I've allocated in C land. Basically, the setup is:
value func1(value args) {
CAMLparam1(args);
CAMLlocal1(ba);
// stuff like alloc shape, fill dims array, etc.
ba = alloc_bigarray(BIGARRAY_INT32 | BIGARRAY_C_LAYOUT,
1, shape, dims);
// other stuff
CAMLreturn(ba);
}
value func2(value args) {
CAMLparam1(args);
CAMLlocal5(blah);
// stuff
blah1 = func1(args);
// stuff like alloc blah5, etc.
Store_field(blah5, 3, blah1);
CAMLreturn(blah5);
}
It appears to me that the bigarray allocation is creating some data on
a stack which then gets reclaimed, as I can't access the bigarray
anymore in func2 (using Data_bigarray_val(blah1) causes a seg fault).
I checked the implementation of caml_ba_alloc to make sure that I
wasn't passing in anything which was allocated on the stack of func1
that was getting placed directly into the bigarray struct but that
seems to be fine.
Any thoughts?
--
Eric Hielscher
"Het zal me worst wezen."
http://ehielscher.org
reply other threads:[~2010-02-15 20:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=d550840e1002151247x76bbdacbp589df7c40e24839e@mail.gmail.com \
--to=hielscher@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).