caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Andy Yang <yyu08@yahoo.com>
To: caml-list@inria.fr
Subject: [Caml-list] Toplevel crashes when trying to call external functions
Date: Sat, 10 Jul 2004 18:20:47 -0700 (PDT)	[thread overview]
Message-ID: <20040711012047.86808.qmail@web53203.mail.yahoo.com> (raw)

Hi, all

I am relatively new to Ocaml. Sorry about the spam if
this is a trivial problem. I am trying to give call
some external functions. 

Some codes are as follows:

value zchaff_InitManager(void)
{
  CAMLparam0();  
  void * solver = SAT_InitManager();
  value val = alloc(1, Custom_tag);
  Int32_val(val) = (int) solver;
  CAMLreturn ( val );
}

void zchaff_ReadCnf(value mng, value filename)
{
  CAMLparam2(mng, filename);
  void* solver = (void*)Int32_val(mng);
  char * fn = String_val(filename);
  read_cnf(solver, fn);  
  CAMLreturn0;
}

When I call these functions in a .ml file. It is okay.
.However, when I tried to call these functions
interactively, segmentation fault happens. The
interactive way is as follows:

# let solver = zchaff_InitManager () ;;
solver = 0x8092328
val solver : zchaff_solver = <abstr>
# Gc.full_major();;
- : unit = ()
# solver ;;
- : zchaff_solver = <abstr>
# let _ = zchaff_ReadCnf solver "testcase/4.cnf";;
solver = 0x400
file = testcase/4.cnf
Segmentation fault

It seems that the variable "solver" is not registered
in Gc's root tree. So solver's value changes after
Gc.full_major(). Where are wrong in my codes? Tracing
with gdb, the stack is as follows when segmentation
fault happens.

#0  0x0807120f in obj_tag ()
#1  0x08074c8f in interprete ()
#2  0x08075dbe in caml_main ()
#3  0x08067a9c in main ()

Thanks a lot!

Andy





		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


             reply	other threads:[~2004-07-11  1:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-11  1:20 Andy Yang [this message]
2004-07-11 18:14 ` art yerkes
2004-07-11 18:58   ` Andy Yang
2004-07-12 11:04     ` Gerd Stolpmann
2004-07-12 11:35     ` Damien Doligez
2004-07-12 13:16       ` Andy Yang
2004-07-12 13:33         ` Olivier Andrieu
2004-07-12 15:39           ` Andy Yang
2004-07-12  6:55 ` Anne Pacalet
2004-07-12  3:39 John Prevost
2004-07-12  4:46 ` Andy Yang
2004-07-12 10:55 ` Gerd Stolpmann
2004-07-12 12:03   ` Richard Jones
2004-07-12 12:55     ` Jean-Christophe Filliatre

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=20040711012047.86808.qmail@web53203.mail.yahoo.com \
    --to=yyu08@yahoo.com \
    --cc=caml-list@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).