Goto Chapter: Top 1 2 3 4 5 6 7 8 9 Ind
 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 

3 Maintaining the GAP kernel and library
 3.1 Debugging the GAP Kernel
 3.2 ...

3 Maintaining the GAP kernel and library

3.1 Debugging the GAP Kernel

The GAP kernel supports a variety of options which can be enabled by running configure which provide various checks which can be useful when writing and debugging GAP kernel code.

The first option, --enable-debug, is well supported and can be used whenever the GAP kernel, or kernel modules, are being developed (although developers should still check their code works without it).

--enable-debug enables assertions throughout the kernel. These assertions are implemented using the GAP_ASSERT macro. These assertions are disabled when GAP is compiled without --enable-debug. When --enable-debug is enabled, KernelDebug will be shown in the line starting Configuration: when GAP is started.

The next two options are more experimental, and are not designed to be constantly enabled. They are particularly designed to track down bugs relating to memory corruption relating to GASMAN (GAP's memory manager). They cannot both be enabled at the same time. These options assume you are familiar somewhat familiar with the internals of GASMAN (see gasman.c for more information). In particular, GASMAN represents memory using an object of type Bag. The contents of these Bags can be moved during garbage collection.

--enable-memory-checking makes GAP check for C pointers to the content of Bags being used after a new Bag has been created or a Bag is resized. GASMAN moves Bags during garbage collection, which can happen whenever a new Bag is created or a Bag is resized. However, as it is very unlikely that any single allocation will cause a garbage collection, these bugs trigger very rarely. Also the problems caused by these bugs are, if the C pointer is written to, a random other Bag, somewhere in GAP, is changed.

After configuring, the memory checking must still be turned on. This can be done either by passing --enableMemCheck to GAP's command line, or calling GASMAN_MEM_CHECK(1). Note that enabling these tests makes GAP VERY, VERY slow. It can (depending on the machine and operating system) take GAP over a day to start, and load all standard packages. The recommending way to use this option is to start GAP, and then load small test files to try to isolate the problem. MemCheck will be shown in the line starting Configuration: when GAP is started.

Known bugs: GAP will crash if IO_fork from the IO package is called while memory checking is enabled.

--enable-valgrind makes changes to GASMAN so it is compatible with the valgrind memory checking program. Without this, Valgrind will report many incorrect warnings relating to GASMAN and no useful warnings.

At present, this --enable-valgrind only checks for invalid writes to the last bag which was created. Also, this option does not do anything unless GAP is run through Valgrind (for example by running valgrind gap.

Modules, PROPOSALs, ...

3.2 ...

...

 [Top of Book]  [Contents]   [Previous Chapter]   [Next Chapter] 
Goto Chapter: Top 1 2 3 4 5 6 7 8 9 Ind

generated by GAPDoc2HTML