slang-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] Re: new slang 2 development snapshot released


"John E. Davis" <davis@xxxxxxxxxxxxx> wrote:
> Joerg Sommer <joerg@xxxxxxxxxxxx> wrote:
>>The problem is caused in line 112 in slimport.c.
>>
>>   if (NULL != find_handle (name))
>>     return 0;			       /* already loaded */
>>
>>There is a check, if the module is already loaded. This is the case, if
>>you have loaded it under the namespace foo. If you define name a little
>>bit better, it should work.
>
> The problem is that SLang_Name_Type[1] objects are stored in hash
> tables in the form of a linked list.  When loading a module into
> another namespace, it is not sufficient to simply reload the module
> without performing a copy of the objects that the module adds to the
> interpreter.  You can see this for yourself by loading the following
> into slsh linked to your patched version of slang.  

I tracked down the problem to this:

The init_MODULE_module_ns() function call SLns_add_intrin_fun_table()
which calls add_generic_table(). There you insert the table entries into
the hash table. For a module you refer to its static
SLang_Intrin_Fun_Type table. If the namespace is imported a second time
you refer to exactly the same memory, which becomes insert into the
second hash table. Because the new entry is inserted at the beginning of
the list, his next pointer refers to the rest. But this is the next
pointer of the static memory of module, which is used likewise in the
hash table of the first namespace. So the entry in the first namespace
points to the hash bucket list of the second namespace.

I think you have the same problem with variables and constants and
similar.

I'm not very familar with the slang internals. I think you must copy the
table entry, befor you alter it. Do you know where this must be done?
Does this influence other functions, which may assume the memory isn't
copied?

Jörg.

-- 
Nichts ist so langweilig, wie die Wiederholung seinerselbst.
                                        (Marcel Reich-Ranicki)

_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]