[gambit-list] __cleanup() problem (OS X 10.6.6 / Gambit-C 4.6.0)

David Dreisigmeyer dwdreisigmeyer at gmail.com
Wed Jan 12 13:43:02 EST 2011


Hi Marc,

Looks like you may have taken care of the Undefined symbols:
"_environ" 2 weeks ago(?):

http://www.iro.umontreal.ca/~gambit/repo/.cgit.cgi/Gambit/commit/?id=efd3292ef4ab236a496cd5ce03aa81cff1ef3052

Everything seems to work now.

One thing is with this:

  /* Cleanup the Scheme library */

  printf ("Starting cleanup...1\n");
  fflush (stdout);

  printf ("Starting cleanup...2\n");
  fflush (stdout);

  ___cleanup ();

  printf ("Cleanup successful\n");
  fflush (stdout);

at the end of client.c, "Cleanup successful\n" is written to test8.out
but is not written out to the terminal ("Starting cleanup...2\n" is
written to both).

I am still getting "Process Python exited abnormally with code 1" when
I call __cleanup().

Thanks again.

-Dave

On Wed, Jan 12, 2011 at 10:57 AM, David Dreisigmeyer
<dwdreisigmeyer at gmail.com> wrote:
> This does fix it.  However, now I'm having trouble building the Python
> module.  (This doesn't involve anything with Python, only Gambit.  I
> never get to the Cython part.)  I installed gambc-v4_6_0-devel with
>
> $ ./configure --enable-single-host --prefix=/Users/daviddreisigmeyer/gambit_test
> $ make install
>
> I get the following errors:
>
> .....
> Undefined symbols:
>  "_environ", referenced from:
>      ____device_stream_setup_from_process in libgambc.a(os_io.o)
>      ____getenv_UCS_2 in libgambc.a(os_shell.o)
>      ____setenv_UCS_2 in libgambc.a(os_shell.o)
>      ____setenv_UCS_2 in libgambc.a(os_shell.o)
>      ____unsetenv_UCS_2 in libgambc.a(os_shell.o)
>      ____os_environ in libgambc.a(os_shell.o)
>      ____cleanup_shell_module in libgambc.a(os_shell.o)
> .....
>
> I don't have this problem with Gambit installed from git, and the
> makefile I'm using works with that version.  The only difference
> between my code and the test8 in gambit/tests is the client.c and
> client.h files:
>
> --------------------------------------------------
> /* client.h */
>
> #include <stdio.h>
> #include <stdlib.h>
> #define ___VERSION 406000
> #include "gambit.h"
> #include "server.h"
>
> int gambit_setup ( void );
> char * gambit_eval ( char* );
> int gambit_cleanup ( void );
> --------------------------------------------------
> /* File: "client.c", Time-stamp: <2007-09-12 00:07:21 feeley> */
>
> #include <stdio.h>
> #include <stdlib.h>
> #define ___VERSION 406000
> #include "gambit.h"
> #include "server.h"
> #define SCHEME_LIBRARY_LINKER ____20_server__
>
> ___BEGIN_C_LINKAGE
> extern ___mod_or_lnk SCHEME_LIBRARY_LINKER (___global_state_struct*);
> ___END_C_LINKAGE
>
> int gambit_setup( void )
> {
>  ___setup_params_struct setup_params;
>  ___setup_params_reset (&setup_params);
>  setup_params.version = ___VERSION;
>  setup_params.linker = SCHEME_LIBRARY_LINKER;
>  ___setup (&setup_params);
>  return 0;
> }
>
>
> char * gambit_eval( char *in_str )
> {
>  char *temp;
>
>  temp = eval_string (in_str);
>  if (temp != 0){
>    printf ("%s\n", temp);
>  } else {
>    printf ("Error: temp == 0\n");
>  }
>  ___release_string (temp);
>  fflush ( stdout );
>  return temp;
> }
>
>
> int gambit_cleanup ( void )
> {
>  fflush ( stdout );
>  ___cleanup ();
>  return 0;
> }
> --------------------------------------------------
>
>
>
> Thanks for all of your help Mark -- I really appreciate it.  Let me
> know if you'll want anything else on my end.
>
> -Dave
>
>
>
> On Wed, Jan 12, 2011 at 9:06 AM, Marc Feeley <feeley at iro.umontreal.ca> wrote:
>>
>> On 2011-01-12, at 8:44 AM, David Dreisigmeyer wrote:
>>
>>> This wasn't used with Python.  I started with modifying the client.c
>>> file included in gambit/tests and proceeded from there.  I'll check on
>>> commenting out the call to release_fn soon.
>>>
>>> Thanks Marc,
>>>
>>> -Dave
>>
>> OK, I misunderstood.  Now I think the problem is that Gambit is closing stdin/stdout/stderr in ___cleanup(), so when you do a printf after the call to ___cleanup, there is no output.
>>
>> Please try this: in lib/os_io.c in function ___device_file_close_raw_virt, replace
>>
>> #ifdef USE_POSIX
>>      if (close_no_EINTR (d->fd) < 0)
>>        return err_code_from_errno ();
>> #endif
>>
>> with
>>
>> #ifdef USE_POSIX
>>      if (d->fd > 2 && close_no_EINTR (d->fd) < 0)
>>        return err_code_from_errno ();
>> #endif
>>
>> This will prevent closing stdin/stdout/stderr.  If that fixes your problem, then I'll try to find a better fix.  By the way I notice this commented out code which seems to be relevant:
>>
>> #if 0
>>        /*
>>         * The file descriptor must be dup'ed so that the standard
>>         * stdin/stdout/stderr are not closed.
>>         */
>>
>> ...
>>
>> Marc
>>
>>
>



More information about the Gambit-list mailing list