[Aldor-l] Bug with macros

Pippijn van Steenhoven pip88nl at gmail.com
Sat Dec 15 13:14:01 EST 2007


Hi Ralf,

On Fri, Dec 14, 2007 at 06:09:05PM +0100, Ralf Hemmecke wrote:
> Interestingly, no segfault happens if the *unused* function degreeN is
> not in the file.

indeed. It works if degreeN is completely empty:

   degreeN(): () == { } -- works, too.

if you let degreeN return a constant value:

   degreeN(r: Knk): Integer == { 3 }

it also works. Further investigation yields that the segfault doesn't happen
in your code at all:

   degreeN(r: Knk): Integer == { coefficient(r,0); 3 } -- also segfaults

so, coefficient() causes a crash at the bottom of the file, if it is
referenced in degreeN. If degree() is referenced in the function degreeN,
degree (p2) crashes when called at the bottom.

What all this has to do with macros.. I have no idea, but I can see that the
program is trying to use a value (5) as pointer to a closure. I don't know
where in your code there is a 5 involved, but what I can also see is that this
line:

   p2: Knk := (n-k+1)^2;

influences it. When ^2 is instead ^3, the value becomes 7 and with ^3, the
value is 9. This determinism at least shows that it is unlikely to be
undefined behaviour. An attempt to run a memory debugger (valgrind) on it made
me laugh and cry at the same time:

   ==13243== More than 10000000 total errors detected.  I'm not reporting any more.
   ==13243== Final error counts will be inaccurate.  Go fix your program!

Aldor is pedantic-all-warnings-gcc-proof and somewhat lint-proof, but sadly,
that seems to have been the main goal of its developers (I have seen several
parts in the code that were obviously inserted just to make lint happy). Also,
I was unable to deduce anything from the memory debugger, because running it
caused:

   #1 (Fatal Error) Storage allocation error (out of memory).

and valgrind ended with

   ==13439== ERROR SUMMARY: 111464622 errors from 85 contexts (suppressed: 0 from 0)

Very funny.. but maybe this helps other people who feel like looking at the
compiler code.

-- 
Pippijn van Steenhoven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://aldor.org/pipermail/aldor-l_aldor.org/attachments/20071215/8b338f71/attachment.bin 


More information about the Aldor-l mailing list