It could be the call to ___release_foreign (in c_intf.c) that's causing the trouble. The calling sequence is:
___cleanup (setup.c) => ___cleanup_mem (mem.c) => free_still_objs (mem.c) => ___release_foreign (c_intf.c)
With this (modified) snippet from free_still_objs:
----------------------------------------------------------------------
if (release_fn != 0) { printf (" >>> ___release_foreign 3a\n"); fflush (stdout); ptr = ___CAST(void*,___FIELD(obj,___FOREIGN_PTR)); ___FIELD(obj,___FOREIGN_RELEASE_FN) = ___CAST(___SCMOBJ,___CAST(___SCMOBJ (*) ___P((void *ptr),()),0));
printf (" >>> ___release_foreign 3b\n"); fflush (stdout); ___FIELD(obj,___FOREIGN_PTR) = ___CAST(___SCMOBJ,___CAST(void*,0));
printf (" >>> ___release_foreign 3c\n"); fflush (stdout); printf (" >>> ___FIX(___NO_ERR) = %i\n" , ___FIX(___NO_ERR)); fflush (stdout); e = release_fn (ptr); printf (" >>> e = release_fn (ptr) : %i\n" , e); fflush (stdout); printf (" >>> ((e = release_fn (ptr)) != ___FIX(___NO_ERR)) = %i\n" , (e != ___FIX(___NO_ERR))); fflush (stdout); if (e != ___FIX(___NO_ERR)) { printf (" >>> ___release_foreign 3d\n"); printf (" >>> e = %d\n" , e); fflush (stdout); return e; } } ----------------------------------------------------------------------
I'll get, e.g., the following output to the terminal:
$ ./client ......
___release_foreign 3a ___release_foreign 3b ___release_foreign 3c ___FIX(___NO_ERR) = 0 e = release_fn (ptr) : 0 ((e = release_fn (ptr)) != ___FIX(___NO_ERR)) = 0
.....
___release_foreign 3a ___release_foreign 3b ___release_foreign 3c ___FIX(___NO_ERR) = 0
$
So maybe release_fn is the problem?
Commenting out the call to ___cleanup_mem in ___cleanup, the code still fails on ___cleanup_os. Here it seems to have something to do with ___device_group_cleanup in os_io.c. Now the call sequence is:
___cleanup (setup.c) => ___cleanup_os (os.c) => ___cleanup_io_module (os_io,c) => io_module_cleanup (os_io,c) => ___device_group_cleanup (os_io.c)
Here it seems to be a problem with the line:
if (___device_cleanup (dgroup->list) != ___FIX(___NO_ERR))
Here I'll get
___device_group_cleanup 2 ___device_group_cleanup 2d
(___device_cleanup (dgroup->list) : 0
___FIX(___NO_ERR) : 0 ___device_group_cleanup 2c
(___device_cleanup (dgroup->list) != ___FIX(___NO_ERR)) = 0
___device_group_cleanup 2b ___device_group_cleanup 2
with this modified snippet in ___device_group_cleanup (os_io.c):
----------------------------------------------------------------------
{ printf ("___device_group_cleanup 2\n"); fflush (stdout);
aa = ___device_cleanup (dgroup->list); printf ("___device_group_cleanup 2d\n"); fflush (stdout); bb = ___FIX(___NO_ERR);
printf (" >>> (___device_cleanup (dgroup->list) : %i\n" , aa); fflush(stdout); printf("___FIX(___NO_ERR) : %i\n",bb); fflush(stdout); printf ("___device_group_cleanup 2c\n"); fflush (stdout); printf (" >>> (___device_cleanup (dgroup->list) != ___FIX(___NO_ERR)) = %d\n" , (aa != bb)); fflush (stdout); if (aa != bb) { printf ("___device_group_cleanup 2a\n"); fflush (stdout); break; } printf ("___device_group_cleanup 2b\n"); fflush (stdout); }
----------------------------------------------------------------------
So maybe ___device_cleanup is causing a problem also?
Thanks again!
-Dave