[plt-scheme] Bus error on scheme_initialize

From: Phil Windley (phil at windley.org)
Date: Wed Mar 30 19:02:56 EST 2005

Thanks to Matthew for the help.

The mzgdbm package is fairly old and used cc and ld directly.  Being 
new to this game, I didn't know about mzc.  I'd played with the 
arguments to cc and ld until I got a "good" library.

Using mzc instead solved the Bus error problem.  On OS X, I had to also 
add "++ldf -framework PLT_MzScheme" on the link step.

My next problem was due to the treatment of strings as arrays of UTF-8 
chars.  gdbm-open doesn't like them.  :-)  Getting a string that could 
be passed to the UNIX library involved doing this:

(char *)SCHEME_CHAR_STR_VAL(scheme_char_string_to_byte_string(argv[0]))

Now, I need to go through the rest of the source and make the treatment 
of strings consistent.

Maybe soon, I can announce that mzgdbm works with 299.100.

--phil--



On Mar 30, 2005, at 7:33, Matthew Flatt wrote:

> At Tue, 29 Mar 2005 21:33:23 -0700, Phil Windley wrote:
>> 1.) Is there something obviously dumb about what happening above?
>
> No, I can't see anything wrong at all. I think maybe we need to see
> more of your file to know what's going wrong.
>
>> 2.) If not, then does just adding the global to the table exercise the
>> code for the function tied to the global (gdbm_open in this case) in
>> such a way that I should look there for the problem?
>
> No, it shouldn't.
>
>> 3.) Other ideas?
>
> Below is a complete (but useless!) extension built around your
> function. This works for me when I compile with
>
>   mzc --cc test.c
>   mzc --ld test.dylib test.o
>
> and then use `load-extension' on "test.dylib".
>
> Does this one work for you? If so, maybe the difference will suggest
> something, or maybe the next step is sending a more complete program to
> the list. If my version doesn't work for you, then a stack trace is
> probably in order to help me figure out what's wrong.
>
> Matthew
>
> ----------------------------------------
>
> #include <escheme.h>
>
> static Scheme_Type scheme_gdbm_file_type;
>
> static Scheme_Object *scheme_gdbm_open(Scheme_Object **a, int c)
> {
>   return scheme_void;
> }
>
> Scheme_Object *scheme_initialize(Scheme_Env *env) {
>
>    Scheme_Object *v;
>
> /* type for GDBM_FILE */
>    scheme_gdbm_file_type=scheme_make_type("<gdbm:file>");
>
> /* Exported functions */
>     v = scheme_make_prim_w_arity(scheme_gdbm_open, "gdbm:open", 1, 3);
>     scheme_add_global("gdbm:open", v, env);
>
>
>     return scheme_void;
> }
>
> Scheme_Object *scheme_reload(Scheme_Env *env) {
>   return scheme_void;
>   /* Likely more useful: do everything that's in
>      scheme_initialize, except making the type. */
> }
>
> Scheme_Object *scheme_module_name() {
>   return scheme_false;
> }
>



Posted on the users mailing list.