[Aldor-l] Bug with macros

Ralf Hemmecke ralf at hemmecke.de
Tue Dec 18 07:22:58 EST 2007


Hi Pippijn

Thank you for looking into this bug.

Pippijn van Steenhoven wrote:
> 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.

Very strange.

 > 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!

Oh, that sounds like we must be happy to get sometimes a running program 
as an output of the Aldor compiler. :-(

> 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.

I have the suspicion, that currently you are the only one with enough 
expertise. To the other experts... please prove me wrong.

Ciao.

Ralf




More information about the Aldor-l mailing list