Dear GAP-Forum,
Jean Michel has reported a bug GAP that may occur if a function reads a file
that executes functions again. While this error can be a nuisance (GAP
crashes with a segmentation fault) it is not dangerous, as it will not
produce any wrong results.
The conditions to produce this error however are very specific, so unless you
deliberately do the following things, you will never encounter this error
and won't need to worry about it.
The error occurs in the following context:
- A function 'fun' defines another function 'hugo'
- It then reads a file.
- This file call 'hugo'.
The following two files, test1 and test2, demonstrate this behaviour.
Reading 'test1' crashes GAP:
--- test1 ---- hugo:=1; # unnecessary, just to please syntax check. fun:=function() hugo:=function()1+1;end; Read("test2"); end; fun(); --- end test1 ---- --- test2 ---- hugo(); --- end test2 ----
The reason for this error seems to be that the function 'hugo' (as it is
defined locally) keeps the environment of the function 'fun'. Reading a file
however resets the environment temporarily to the global environment (all
variable definitions in the file are global variables). As in this situation
the environment of 'fun' is still actual when reading the file 'test2' and
calling 'hugo' uses this environment, GAP gets confused.
Unfortunately we don't yet have a remedy for this error. Fixing it may
be difficult, as this error is somehow inherent to the design of locally
defined functions and the file read mechanism. (However, it will not happen
in the next version, GAP4, currently under development.)
We are sorry for any problems this error may cause.
Alexander