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=efd3292...
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@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@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
Afficher les réponses par date
On 2011-01-12, at 1:43 PM, David Dreisigmeyer wrote:
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=efd3292...
Yes... I was just going to mention it.
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
It sounds like a bad interaction between Gambit's terminal settings and Python's.
Try commenting out the body of ___device_tty_cleanup in lib/os_tty.c so that you only keep:
return ___FIX(___NO_ERR);
Then try to only keep
#ifdef USE_POSIX if (close (d->fd) < 0) return err_code_from_errno (); #endif
return ___FIX(___NO_ERR);
Let me know which combination works.
Marc
Niether of these worked for Python. However, the first one did cause "Cleanup successful\n" to be printed to the screen when calling client in gambit/tests.
Try commenting out the body of ___device_tty_cleanup in lib/os_tty.c so that you only keep:
return ___FIX(___NO_ERR);
Then try to only keep
#ifdef USE_POSIX if (close (d->fd) < 0) return err_code_from_errno (); #endif
return ___FIX(___NO_ERR);
On 2011-01-12, at 2:36 PM, David Dreisigmeyer wrote:
Niether of these worked for Python. However, the first one did cause "Cleanup successful\n" to be printed to the screen when calling client in gambit/tests.
Good to know.
For the Python problem could you comment out each line of ___cleanup_os in turn to see which call causes the problem :
void ___cleanup_os ___PVOID { ___cleanup_io_module (); ___cleanup_tty_module (); ___cleanup_dyn_module (); ___cleanup_files_module (); ___cleanup_shell_module (); ___cleanup_time_module (); ___cleanup_base_module (); }
___cleanup_os is at the end of lib/os.c .
Marc