chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] Embedding Chicken 4.6.0 on 64-bit Linux


From: Dmitri Rubinstein
Subject: [Chicken-users] Embedding Chicken 4.6.0 on 64-bit Linux
Date: Tue, 26 Apr 2011 00:32:07 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8

Hi. I can't get running the Chicken embedding example from manual on 64-bit Linux. It compiles and runs but produces segmentation fault:

./x
data: 755d9d90
Segmentation fault

When compiling in debug mode gdb reports segmentation fault here:

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff76ead1d in f_9666 (t1=140737353820928, t2=140737488333680, t3=4) at eval.c:5243
5243    t5=C_copy_result_string(t1,t3,t4);

It is possibly 64-bit related problem since compiling Chicken and example application with -m32 flag produces following error instead of segmentation fault:

./x
data: f712770c

Error: (apply) parameter limit exceeded

        Call history:

        x.scm:8: return-to-host 
        <syntax>    (bar)
        <eval>      (bar) <--


Here is the example that I am trying to run:

 % cat x.scm
 ;;; x.scm

 (define (bar x) (gc) (* x x))

 (define-external (baz (int i)) double
   (sqrt i))
 (return-to-host)

 % cat y.c
 /* y.c */

 #include <chicken.h>
 #include <assert.h>

 extern double baz(int);

 int main() {
   char buffer[ 256 ];
   int status;
   C_word val = C_SCHEME_UNDEFINED;
   C_word *data[ 1 ];

   data[ 0 ] = &val;

   CHICKEN_run(C_toplevel);

   status = CHICKEN_read("(bar 99)", &val);
   assert(status);

   C_gc_protect(data, 1);

   printf("data: %08x\n", val);

   status = CHICKEN_eval_string_to_string("(bar)", buffer, 255);
   assert(!status);

   CHICKEN_get_error_message(buffer, 255);
   printf("ouch: %s\n", buffer);

   status = CHICKEN_eval_string_to_string("(bar 23)", buffer, 255);
   assert(status);

   printf("-> %s\n", buffer);
   printf("data: %08x\n", val);

   status = CHICKEN_eval_to_string(val, buffer, 255);
   assert(status);
   printf("-> %s\n", buffer);

   printf("->` %g\n", baz(22));

   return 0;
 }

 % csc x.scm y.c -embedded

Greetings

Dmitri




reply via email to

[Prev in Thread] Current Thread [Next in Thread]