POV-Ray : Newsgroups : povray.general : povray crashes on multiplication? Server Time
31 Jul 2024 04:26:57 EDT (-0400)
  povray crashes on multiplication? (Message 1 to 8 of 8)  
From: stevenvh
Subject: povray crashes on multiplication?
Date: 2 Dec 2007 15:00:01
Message: <web.47530db5ce3f99a0e99dba500@news.povray.org>
Hi,
I'm using a macro which is called only a few (7) times:

/* code starts here *********************************************************/
#macro DrawShelfSection( aLeft, aRight, aY, aSlanting )
    #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );
    ...
    #declare xx = Left;
    #while (xx < Right)
        ...
        #if (xx + Bwidth <= Right)
            DrawBook( xx, aY, Bheight, Bwidth, aSlanting, RandomColor > )
        #end
        #declare xx = xx + Bwidth * InvCosSl;
    #end
#end
/* code ends here ***********************************************************/

When I start rendering the "tokens parsed" counter starts and runs until POVray
crashes at about 270 million (!) tokens parsed.
When I change the last declaration to

    #declare xx = xx + Bwidth;

everything runs fine (with only 660000 tokens parsed).
I first thought the error may have been caused by the 10000x10000 pixel image,
but it also happens on a 500x500.
You can find the error msg dialog at http://www.nenya.be/temp/povray_err.png.

Ideaz anyone?
TIA
Steven


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: povray crashes on multiplication?
Date: 2 Dec 2007 15:10:07
Message: <4753111f$1@news.povray.org>

> /* code starts here *********************************************************/
> #macro DrawShelfSection( aLeft, aRight, aY, aSlanting )
>     #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );
>     ...
>     #declare xx = Left;
>     #while (xx < Right)
>         ...
>         #if (xx + Bwidth <= Right)
>             DrawBook( xx, aY, Bheight, Bwidth, aSlanting, RandomColor > )
>         #end
>         #declare xx = xx + Bwidth * InvCosSl;
>     #end
> #end
> /* code ends here ***********************************************************/
> 

Could you post the *full* code, including DrawBook() and without the 
'...' replacement? Or even better, remove other stuff until the code is 
"small enough" but *still* causes the crash (= a minimal testcase to 
reproduce the crash).


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: povray crashes on multiplication?
Date: 2 Dec 2007 15:24:21
Message: <47531475$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

stevenvh wrote:
> Hi,
> I'm using a macro which is called only a few (7) times:
> 
> /* code starts here *********************************************************/
> #macro DrawShelfSection( aLeft, aRight, aY, aSlanting )
>     #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );
>     ...
>     #declare xx = Left;
>     #while (xx < Right)
>         ...
>         #if (xx + Bwidth <= Right)
>             DrawBook( xx, aY, Bheight, Bwidth, aSlanting, RandomColor > )
>         #end
>         #declare xx = xx + Bwidth * InvCosSl;
>     #end
> #end
> /* code ends here ***********************************************************/
> 
> When I start rendering the "tokens parsed" counter starts and runs until POVray
> crashes at about 270 million (!) tokens parsed.
> When I change the last declaration to
> 
>     #declare xx = xx + Bwidth;
> 
> everything runs fine (with only 660000 tokens parsed).
> I first thought the error may have been caused by the 10000x10000 pixel image,
> but it also happens on a 500x500.
> You can find the error msg dialog at http://www.nenya.be/temp/povray_err.png.
> 
> Ideaz anyone?

	My bet is: at least once in the full code, you call your macro with
a value of aSlanting which causes the cos to be negative, at which
point your macro goes left indefinitely and never reaches the
"Right" position...

		Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
|    mailto:jeb### [at] freefr      | ICQ:    238062172            |
|    http://jeberger.free.fr/     | Jabber: jeb### [at] jabberfr   |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHUxRzd0kWM4JG3k8RAjDGAKCOd7tkafVSB4upitJPSSHdjaKJ9wCglC2b
YQSeFNApkRcWu3VJZfnONK4=
=t9LF
-----END PGP SIGNATURE-----


Post a reply to this message

From: stevenvh
Subject: Re: povray crashes on multiplication?
Date: 2 Dec 2007 16:15:00
Message: <web.47531fe3e9e16078e99dba500@news.povray.org>
Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:

> Could you post the *full* code, including DrawBook() and without the
> '...' replacement? Or even better, remove other stuff until the code is
> "small enough" but *still* causes the crash (= a minimal testcase to
> reproduce the crash).

Hi Nicolas,
thanks for your reply. I was stripping unnecessay code until I had only a few
dozen lines left when I spotted a logical error in my code:

    #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );

should of course be

    #declare InvCosSl = 1 / cos ( pi * aSlanting / 180 );

and now it seems to be OK. Playing a bit with the argument of cos() I noticed
that POVray goes bananas if the argument falls outside [-pi/2, pi/2].
Is there any reason why it won't accept just any real number, as cos() should?

Steven


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: povray crashes on multiplication?
Date: 2 Dec 2007 17:18:08
Message: <47532f20$1@news.povray.org>

> Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
> 
>> Could you post the *full* code, including DrawBook() and without the
>> '...' replacement? Or even better, remove other stuff until the code is
>> "small enough" but *still* causes the crash (= a minimal testcase to
>> reproduce the crash).
> 
> Hi Nicolas,
> thanks for your reply. I was stripping unnecessay code until I had only a few
> dozen lines left when I spotted a logical error in my code:

A minimal testcase would be still useful for the devs to find the cause 
of the unhandled exception (which should never happen, no matter what 
the SDL code does).


Post a reply to this message

From: "Jérôme M. Berger"
Subject: Re: povray crashes on multiplication?
Date: 2 Dec 2007 17:21:28
Message: <47532fe8$1@news.povray.org>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

stevenvh wrote:
> Nicolas Alvarez <nic### [at] gmailisthebestcom> wrote:
> 
>> Could you post the *full* code, including DrawBook() and without the
>> '...' replacement? Or even better, remove other stuff until the code is
>> "small enough" but *still* causes the crash (= a minimal testcase to
>> reproduce the crash).
> 
> Hi Nicolas,
> thanks for your reply. I was stripping unnecessay code until I had only a few
> dozen lines left when I spotted a logical error in my code:
> 
>     #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );
> 
> should of course be
> 
>     #declare InvCosSl = 1 / cos ( pi * aSlanting / 180 );
> 
> and now it seems to be OK. Playing a bit with the argument of cos() I noticed
> that POVray goes bananas if the argument falls outside [-pi/2, pi/2].
> Is there any reason why it won't accept just any real number, as cos() should?
> 
	Sure there is: read my reply to your first post ;)

		Jerome
- --
+------------------------- Jerome M. BERGER ---------------------+
|    mailto:jeb### [at] freefr      | ICQ:    238062172            |
|    http://jeberger.free.fr/     | Jabber: jeb### [at] jabberfr   |
+---------------------------------+------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHUy/nd0kWM4JG3k8RAqHBAJ0c/702BfkWlaFtN0lsEIfvRYvoQwCglFYT
M++nMVuvkjRAYSNtWS2q2pU=
=cAAi
-----END PGP SIGNATURE-----


Post a reply to this message

From: Alain
Subject: Re: povray crashes on multiplication?
Date: 3 Dec 2007 09:46:32
Message: <475416c8$1@news.povray.org>
stevenvh nous apporta ses lumieres en ce 2007/12/02 14:55:
> Hi,
> I'm using a macro which is called only a few (7) times:
> 
> /* code starts here *********************************************************/
> #macro DrawShelfSection( aLeft, aRight, aY, aSlanting )
>     #declare InvCosSl = 1 / cos ( 180 * aSlanting / pi );
>     ...
>     #declare xx = Left;
>     #while (xx < Right)
>         ...
>         #if (xx + Bwidth <= Right)
>             DrawBook( xx, aY, Bheight, Bwidth, aSlanting, RandomColor > )
>         #end
>         #declare xx = xx + Bwidth * InvCosSl;
>     #end
> #end
> /* code ends here ***********************************************************/
> 
> When I start rendering the "tokens parsed" counter starts and runs until POVray
> crashes at about 270 million (!) tokens parsed.
> When I change the last declaration to
> 
>     #declare xx = xx + Bwidth;
> 
> everything runs fine (with only 660000 tokens parsed).
> I first thought the error may have been caused by the 10000x10000 pixel image,
> but it also happens on a 500x500.
> You can find the error msg dialog at http://www.nenya.be/temp/povray_err.png.
> 
> Ideaz anyone?
> TIA
> Steven
> 
> 
> 
The variable "InvCosSl" can go negative. I suggest using the absolute value. 
Also, "cos ( 180 * aSlanting / pi )" can evaluate to a very small, even zero, 
value, resulting in an extremely large value (overflow) or a divide by zero 
error. In fact, you evaluate a cotangent, a functions with asymptotic lines.

-- 
Alain
-------------------------------------------------
   My wife likes to talk on the phone during sex; she called me from Chicago 
last night.
	Rodney Dangerfield


Post a reply to this message

From: stevenvh
Subject: Re: povray crashes on multiplication?
Date: 4 Dec 2007 05:15:00
Message: <web.47552864e9e16078e99dba500@news.povray.org>
Alain <ele### [at] netscapenet> wrote:
> In fact, you evaluate a cotangent, a functions with asymptotic lines.

No, I don't :-). Cotangent would be cos()/sin(), whereas I use 1/cos().
I agree that an infinite loop problem arises when cos() goes negative; that was
the origin of my problem. But that was due to a programming error; (it had been
a long day :-))  in my application aSlanting is limited to just a few degrees.

As for Nicolas' request to post the code, I'm afraid I inadvertently changed it,
since now it just reports an out-of-memory error. As any infinite loop would do.

Muchas gracias, et merci beaucoup, all of you
Steven


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.