Subject: [clisp-list] setf causing stack overfl. w/ hash-table

From: Roland <[email-masked]>
Date: Wed Dec 18 13:15:04 2002

Hello,

I'm using CLISP 2.30 on Windows NT.

The following will cause a stack overflow:

(let ((table (make-hash-table)))
   (setf (gethash 'self table) table))

*** - Lisp stack overflow. RESET

I suppose this is a bug.
I'm not subscribing to this list, so I would appreciate any feedback.If my 
email doesn't appear reach me at:

(map 'string #'code-char '(114 111 108 97 110 100 64 110 101 116 113 117 97 
110 116 46 99 111 109 46 98
  114))

Thanks,
Roland

---

From: Sam Steingold <[email-masked]>
Date: Wed Dec 18 15:51:04 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] setf causing stack overfl. w/ hash-table"
> * Sent on Wed, 18 Dec 2002 19:17:15 -0200
> * Honorable Roland <[email-masked]> writes:
>

<http://clisp.cons.org/faq.html#stack>:

        * You will always get a stack overflow when you try to print a
          circular object (list or structure) and *PRINT-CIRCLE* is NIL.
          Just set *PRINT-CIRCLE* to T.

> I'm not subscribing to this list, so I would appreciate any
> feedback.If my email doesn't appear reach me at:

you can read this list on gmane.org.
note that not everyone on this list will honor such a request.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
Those who value Life above Freedom are destined to lose both.

---

From: Kaz Kylheku <[email-masked]>
Date: Wed Jan 15 12:05:33 2003

CLISP contains a foreign function and foreign variable registry keyed on 
symbol name, which forbids duplicate registration. If you happen to have 
two FFI modules in your image which try to target the same library 
function, you get a nasty error, such as:

    *** - A foreign function "strerror" already exists
    1. Break [2]>

This is a problem because you have to write your own wrappers for every
library function to ensure it has a unique name, or else risk clashing
with other pwople's modules that you don't even know about. Or you can
use some GNU toolchain extensions to create symbol aliases, if you
don't want wrappers, but that's still annoying.

It would be nice if the foreign function hash table was keyed on something 
other in addition to the name, like maybe it could be an #'equal table
keyed on (list function-name package-name), and some way to specify the
that second element could be worked into the def-call-* macros. Or they
could implicitly pick it up from the current *package*, even.

This seems like a bit of work, because it affects what goes into the .c 
file generated from the FFI .lisp module. E.g. this:

    void module__unix__init_function_2(module)
      var module_t* module;
    {
      register_foreign_function(&strerror,"strerror",1024);
      /*...*/
    }

has to become this:

    void module__unix__init_function_2(module)
      var module_t* module;
    {
      register_foreign_function(&strerror,"strerror","MYPACKAGE",1024);
      /*...*/
    }

And of course register_foreign_function and register_foreign_variable
have to be changed and every place that refers to the hash table and so
forth.

Any other ideas? What if, quite simply, duplicate registrations were
silently permitted? What would break?