POV-Ray

The Persistence of Vision Raytracer (POV-Ray).

This is the legacy Bug Tracking System for the POV-Ray project. Bugs listed here are being migrated to our github issue tracker. Please refer to that for new reports or updates to existing ones on this system.

Attached to Project: POV-Ray
Opened by Grimbert Jérôme - 2011-08-20
Last edited by Christoph Lipka - 2011-09-13

FS#218 - Benchmark must be updated to not reference a #local array outside a macro

Lines 1217, 1241 and 1242 of benchmark.cpp must be change to use #declare instead of local for A and its elements.
(because A is returned by the macro)

	"#macro L_GetVN(ResSpl)\n"
	"   #local I = 0;\n"
	"   #declare A = array[ResSpl+1][2]\n"                      //  <============== this is line 1217
	"   #while (I<=ResSpl)\n"
	"      #local P0 = 0+<FnA(I/ResSpl), I/ResSpl, 0>;\n"
	"      #if (P0.x=0 & P0.z=0)\n"
	"         #local P0 = <1e-25,P0.y,1e-25>;\n"
	"      #end\n"
	"      #if (I=0)\n"
	"         #local P1 = 0+<FnA(((I-0.5)/ResSpl)), I/ResSpl, 0>;\n"
	"         #local P2 = 0+<FnA(((I+0.5)/ResSpl)), I/ResSpl, 0>;\n"
	"      #else\n"
	"         #local P1 = P2;\n"
	"         #local P2 = 0+<FnA(((I+0.5)/ResSpl)), I/ResSpl, 0>;\n"
	"      #end\n"
	"      #local P3 = vrotate(P0,<0,1,0>);\n"
	"      #local P4 = vrotate(P0,<0,-1,0>);\n"
	"      #local B1 = P4-P0;\n"
	"      #local B2 = P2-P0;\n"
	"      #local B3 = P3-P0;\n"
	"      #local B4 = P1-P0;\n"
	"      #local N1 = vcross(B1,B2);\n"
	"      #local N2 = vcross(B2,B3);\n"
	"      #local N3 = vcross(B3,B4);\n"
	"      #local N4 = vcross(B4,B1);\n"
	"      #local N = vnormalize((N1+N2+N3+N4)*-1);\n"
	"      #declare A[I][0] = P0;\n"                               // <============== this is line 1241
	"      #declare A[I][1] = N;\n"
	"      #local I = I+1;\n"
	"   #end\n"
	"   A\n"
	"#end\n"

Same update should also be reported into the distributed scene benchmark.pov

Closed by  Christoph Lipka
Tuesday, 13 September 2011, 03:49 GMT
Reason for closing:  Not a bug
Additional comments about closing:  

As of change #5487, constructs as used in the benchmark scene are to be considered proper use of SDL, making the proposed change of the benchmark obsolete. If any problems still persist, please comment to  FS#208 .

Thorsten Fröhlich commented on Sunday, 21 August 2011, 04:09 GMT

Why is this change necessary? The file is perfectly legal syntax.

Grimbert Jérôme commented on Sunday, 21 August 2011, 07:22 GMT

Please have a look at the original (not the cited code, which is already updated for your convenience).

#macro ...
#local A=array...
...
#local A[I][0]=...
#local A[I][1]=...
...
A
#end

The issue is that the array and its elements are deleted at the exit of the macro (that's what #local are for), but the caller of the macro will be accessing A... it works only because the released memory has not been cleared or already reused.

Thorsten Fröhlich commented on Tuesday, 23 August 2011, 04:51 GMT

Hmm, seems perfectly legal to me. The return should be by copy, not my reference. Can you confirm that this did not work in 3.1 to 3.6? If it worked before, there must have been a bug introduced within the last decade...

Grimbert Jérôme commented on Tuesday, 23 August 2011, 05:53 GMT

Looking at 3.6.1 parse.cpp for confirmation.

If the code was

#macro B(LeftSide,...)
...
#local A=array ...
...
#declare LeftSide = A
...
#end

Then it would be ok, as LeftSide would get an actual copy of A (performed by Parse_RValue inside the scope of the macro)

But the code is

#macro B(...)
...
#local A=array...
...
A
#end

#declare LeftSide=B(...)

Parse_RValue is still trying to perform a copy, but it's the copy of an object that has been released when #end was reached.

The sad trick is that there is an explicit copy syntax for spline:

#macro C(...)
#local S=spline...
...
spline(S)
#end

is perfectly legal (whereas just using S would fails the same way: S is deleted at the time #end is reached).

Alas, there is no such explicit copy for array.

As long as your alloc & free library does not overwrite the released segments, you are just referencing freshly released structure to make a new copy.
Hopefully, you won't be allocating the same pointer than your released one, so the copy can happen...
If you compile with dmalloc library (debug malloc) and set it to use the free-blank features, you are in trouble: it will never work.

Admin
Christoph Lipka commented on Thursday, 25 August 2011, 12:46 GMT

I think this is not a bug in the benchmark, but rather in the parser.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing