Subject: [clisp-list] modules initialization, package and crashes

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Fri Apr 5 03:12:02 2002

Hi,

CLISP's external modules are initialized very early while starting
up. For instance,
o init_streamvars() has not yet been called (setting *TERMINAL-IO* etc.)
o init_packages() has not yet been called when starting without -M
o and many others as well...

CLISP catches the attempt by modules to define Lisp functions
(e.g. LISPFUN) in an unknown package (spvw.d:init_other_modules):
 { var object pack = find_package(asciz_to_string(packname,O(internal_encoding)));
   if (nullp(pack)) # Package nicht gefunden?
   { asciz_out_ss(GETTEXTL("module `%s' requires package %s." NLstring),
                  module->name, packname);
-> "module `mtest' requires package TESTCI."

But it cannot do so for arbitrary objects, e.g. the symbol
TESTCI::DECIDER that Peter Wood tries to use. It attempts to read them
via a string-input-stream, so a package error is signaled. As
init_streamvars() has not yet been called, a suberror follows about
*TERMINAL-IO*. Why it crashes later on I don't know - it should not.

It's not just a package problem. Any error signaled while reading the
object_tab to initialize an object causes CLISP to die.

I don't know why in the LISPFUN case an error is signaled instead of
just creating a virgin package. Maybe because CLISP was not
initialized far enough, maybe because that would have disturbed later
FIND-PACKAGE checks in Lisp code.

I don't know why init_other_modules_2() (esp. stream_read) etc. are
called that early in the process.

There may be excellent reasons for all these. Only Bruno Haible could tell.

I don't know what to do yet.

Regards,
	Jörg Höhle.

---

From: Sam Steingold <[email-masked]>
Date: Tue Apr 16 11:11:54 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] modules initialization, package and crashes"
> * Sent on Fri, 5 Apr 2002 13:10:58 +0200
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>

The appended patch appears to fix the problem.
Bruno, Joerg, do you like it?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
Read, think and remember! <http://www.iris.org.il> <http://www.memri.org/>
<http://www.palestine-central.com/> <http://www.mideasttruth.com/>
Beauty is only a light switch away.

Index: src/spvw.d
===================================================================
RCS file: /cvsroot/clisp/clisp/src/spvw.d,v
retrieving revision 1.181
diff -u -w -b -r1.181 spvw.d
--- src/spvw.d	24 Mar 2002 21:08:08 -0000	1.181
+++ src/spvw.d	16 Apr 2002 18:08:18 -0000
@@ -2523,7 +2523,6 @@
     loadmem(argv_memfile);
   # init O(current_language)
   O(current_language) = current_language_o(language);
-  init_other_modules_2(); # initialize modules yet uninitialized
   # set current evaluator-environments to the toplevel-value:
   aktenv.var_env   = NIL;
   aktenv.fun_env   = NIL;
@@ -2587,6 +2586,7 @@
   init_dependent_encodings();
   # initialize stream-variables:
   init_streamvars(!(argv_execute_file == NULL));
+  init_other_modules_2(); # initialize modules yet uninitialized
  #ifdef NEXTAPP
   # make nxterminal-stream functional:
   if (nxterminal_init()) { final_exitcode = 17; quit(); }