POV-Ray : Newsgroups : povray.bugreports : #write Server Time
22 Nov 2024 11:24:29 EST (-0500)
  #write (Message 1 to 10 of 19)  
Goto Latest 10 Messages Next 9 Messages >>>
From: Anthony D  Baye
Subject: #write
Date: 28 Feb 2016 14:00:00
Message: <web.56d342e38bb35b79fd6b6fe10@news.povray.org>
PoV throws a segmentation fault on a malformed #write statement.

e.g. #write(fileHandle, arg1 [, ...] // no closing paren.

Regards,
A.D.B.


Post a reply to this message

From: clipka
Subject: Re: #write
Date: 29 Feb 2016 00:09:06
Message: <56d3d272$1@news.povray.org>
Am 28.02.2016 um 19:56 schrieb Anthony D. Baye:
> PoV throws a segmentation fault on a malformed #write statement.
> 
> e.g. #write(fileHandle, arg1 [, ...] // no closing paren.

Are you using the leatest and greatest version?


Post a reply to this message

From: Anthony D  Baye
Subject: Re: #write
Date: 29 Feb 2016 00:30:01
Message: <web.56d3d65aa95e761bfd6b6fe10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 28.02.2016 um 19:56 schrieb Anthony D. Baye:
> > PoV throws a segmentation fault on a malformed #write statement.
> >
> > e.g. #write(fileHandle, arg1 [, ...] // no closing paren.
>
> Are you using the leatest and greatest version?

The datestamp on my build folder indicates that it was compiled on 2 Aug.

I haven't heard about any new releases, and it's not like I make a habit of
recompiling regularly.

Regards,
A.D.B.


Post a reply to this message

From: clipka
Subject: Re: #write
Date: 29 Feb 2016 00:53:28
Message: <56d3dcd8$1@news.povray.org>
Am 29.02.2016 um 06:25 schrieb Anthony D. Baye:
> clipka <ano### [at] anonymousorg> wrote:
>> Am 28.02.2016 um 19:56 schrieb Anthony D. Baye:
>>> PoV throws a segmentation fault on a malformed #write statement.
>>>
>>> e.g. #write(fileHandle, arg1 [, ...] // no closing paren.
>>
>> Are you using the leatest and greatest version?
> 
> The datestamp on my build folder indicates that it was compiled on 2 Aug.

And what version does POV-Ray claim to be?

> I haven't heard about any new releases,

I'm currently cranking out changes and even Windows builds at such a
rate that I've ceased to announce them ;)

> and it's not like I make a habit of recompiling regularly.

Fair enough.
In this case, however, I recall having fixed a similar bug or two in the
past, so there's a chance that this particular issue has been fixed as well.

Also, I haven't been able to reproduce the problem myself so far, even
with POV-Ray 3.7.0, so I need you as a guinea pig ;)


Post a reply to this message

From: Anthony D  Baye
Subject: Re: #write
Date: 29 Feb 2016 01:25:00
Message: <web.56d3e313a95e761bfd6b6fe10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 29.02.2016 um 06:25 schrieb Anthony D. Baye:
> > clipka <ano### [at] anonymousorg> wrote:
> >> Am 28.02.2016 um 19:56 schrieb Anthony D. Baye:
> >>> PoV throws a segmentation fault on a malformed #write statement.
> >>>
> >>> e.g. #write(fileHandle, arg1 [, ...] // no closing paren.
> >>
> >> Are you using the leatest and greatest version?
> >
> > The datestamp on my build folder indicates that it was compiled on 2 Aug.
>
> And what version does POV-Ray claim to be?
>
> > I haven't heard about any new releases,
>
> I'm currently cranking out changes and even Windows builds at such a
> rate that I've ceased to announce them ;)
>
> > and it's not like I make a habit of recompiling regularly.
>
> Fair enough.
> In this case, however, I recall having fixed a similar bug or two in the
> past, so there's a chance that this particular issue has been fixed as well.
>
> Also, I haven't been able to reproduce the problem myself so far, even
> with POV-Ray 3.7.0, so I need you as a guinea pig ;)

Well, I don't really have time for a rebuild right now, but it says
3.7.0-unofficial when I do povray --version

I don't know how you find anything with sparse comments and God functions
pushing a thousand lines long plus macros.

Regards,
A.D.B.


Post a reply to this message

From: clipka
Subject: Re: #write
Date: 29 Feb 2016 04:15:36
Message: <56d40c38$1@news.povray.org>
Am 29.02.2016 um 07:20 schrieb Anthony D. Baye:

> Well, I don't really have time for a rebuild right now, but it says
> 3.7.0-unofficial when I do povray --version

Now that's a bit older than last August; virtually everything since
August 2014 identifies as "3.7.X-alpha.XXXXXXX".

> I don't know how you find anything with sparse comments and God functions
> pushing a thousand lines long plus macros.

Yeah, the inherited stuff isn't ideal, and the parser is the worst part
of it all.


Post a reply to this message

From: Anthony D  Baye
Subject: Re: #write
Date: 1 Mar 2016 01:25:00
Message: <web.56d533aba95e761bfd6b6fe10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 29.02.2016 um 07:20 schrieb Anthony D. Baye:
>
> > Well, I don't really have time for a rebuild right now, but it says
> > 3.7.0-unofficial when I do povray --version
>
> Now that's a bit older than last August; virtually everything since
> August 2014 identifies as "3.7.X-alpha.XXXXXXX".
>
> > I don't know how you find anything with sparse comments and God functions
> > pushing a thousand lines long plus macros.
>
> Yeah, the inherited stuff isn't ideal, and the parser is the worst part
> of it all.

Rebuilt using the latest master.  Bug's still there.
remove the closing paren at line 180 and try rendering.  It gives me a segfault.

Regards,
A.D.B.

#version 3.7;

#include "math.inc"
#include "functions.inc"
#include "kolors.inc"
#include "metals.inc"
#include "stones.inc"

#default {
    pigment { rgb <0.07,0.37,0.75> }
    finish { ambient 0 }
    }

/* !- Global Switches -! */
#declare RAD = off      ;
#declare PHO = off      ;
/* --------------------- */

global_settings {
#if(RAD)
    radiosity {
        pretrace_start 0.04
        pretrace_end   0.005
        count 300

        nearest_count 10
        error_bound 0.110
        recursion_limit 2

        low_error_factor 0.2
        gray_threshold 0.2
        minimum_reuse 0.015
        brightness 0.618
        normal on

        adc_bailout 0.01/2
       }
#end

#if (PHO)
    photons {
        count 20000
        autostop 0
        jitter 0.4
        media 50, 30
        }
#end
     assumed_gamma 1.0
     max_trace_level 15
     }

light_source { <3.0, 6.0, -7.0> rgb 1 }
camera {
    perspective
//    location <0.0, 4.0, -5.0>
    location <0.0, 5.0, -15.0>
    up y
    right x*(image_width/image_height)
//    look_at <0.0, 3.0, 0.0>
    look_at 5*y
//    focal_point <0.0, 5.0, 0.0>
//    aperture 0.3
//    blur_samples 20
    }

// curtesy of Tim Atwood
#declare Cast_Metal =
texture {
   pigment{Gray05}
   normal{facets coords 1 scale 0.1}
   finish {
      ambient 0.10
      brilliance 2
      diffuse 0.4
      metallic
      specular 0.50
      roughness 5/60
      reflection 0.1
   }
   scale 0.35
}

// plane { y, 0 pigment { rgb 1 } }

//#include "column.inc"

#declare unit_hex_major =
prism {
    linear_spline
    0.0, 1.0, 7
    #local T = 30;
    #while(T <= 390)
        <sind(T), cosd(T)>
    #local T = T + 60;
    #end
    }

// A hexagon measuring one unit from the center to the center of each face.
#declare unit_hex_minor =
object { unit_hex_major scale 1/<cosd(30), 1, cosd(30)> }

#declare hex_pig =
pigment {
        object { unit_hex_major color Black color Red }
    }

#macro ply_header(FMT, VRS, ATH, DSC, VCT)
array[9] {
    "ply\r\n",
    concat("format " FMT, " ", str(VRS,1,1), "           { ascii/binary, format
version number }\r\n"),
    concat("comment made by ", ATH, "     { comments keyword specified, like all
lines }\r\n"),
    concat("comment ", DSC, "\r\n"),
    concat("element vertex ", str(VCT, 0,0), "          { define \"vertex\"
element, ", str(VCT,0,0), " of them in file }\r\n"),
    "property float x           { vertex contains float \"x\" coordinate }\r\n",
    "property float y           { y coordinate is also a vertex property }\r\n",
    "property float z           { z coordinate, too }\r\n",
    "end_header                 { delimits the end of the header }\r\n"
    }
#end

#declare f_sagitta = function(x,y,z,R,P) { 2 * R * pow( sin(pi / (2*P)), 2) }
#declare f_apothem = function(x,y,z,R,P) { R - f_sagitta(x,y,z,R,P) }
#declare f_part_01 = function(x,y,z,R) { R*sin(pi/3 + mod(f_th(x,y,z), pi/3)) }
#declare f_part_02 = function(x,y,z,R) { f_part_01(x,y,z,R) -
f_apothem(x,y,z,R,6) }
#declare r_fun = function(x,y,z,R) { R - f_part_02(x,y,z,R) / sin(pi/3 +
mod(f_th(x,y,z), pi/3)) }
#declare f_hex_face = function { sqrt( x*x + z*z ) - r_fun(x,y,z,1) }
#declare hex_fn = function { pigment { hex_pig } }
#declare p_fn_x = function(x,y,z,O) { x - O }

#macro write_ply(FILENAME, HEADER, DATA)
    #fopen pCloudFile FILENAME write
        #for(L,0,dimension_size(HEADER,1)-1,1)
            #write(pCloudFile, HEADER[L])
        #end
        #for(P,0,dimension_size(DATA,1)-1,1)
            #write(pCloudFile, vstr(3, DATA[P], " ",0,6), "\r\n")
        #end
    #fclose pCloudFile
#end

#local R0 = 1;      // circumradius
#local N = 6;
#local P = 1/5;
#local sagitta = 2 * R0 * pow( sin( pi / (2 * N) ), 2 );
#local apothem = R0 - sagitta;      // inradius
#local r = 360 / N;
#local l = 90 - r/2;
#local dS = 0.0625;      // S = RT --> T = S/R  tf. dT = dS/R
#local pC = 0;
#local heightMax = 10;
#local heightDelta = 0.03125;
#local pointDelta = 3;
#local DStore = array[(360/pointDelta)*(heightMax/heightDelta + 1)]
#local layercount = 0;
//#write(pCloudFile, "0.000000 0.000000 0.000000\r\n")
#for(H,0,heightMax,heightDelta)
union {
    #for(T,0,360-pointDelta,pointDelta)
        #local p1 = R0*(sind(l + mod(T, r)));
        #local p2 = p1 - apothem;
        #local R1 = R0 - p2/sind(l + mod(T, r));
        #local v0 = vrotate(<R1,H,0>, (T + degrees((H*P*pi)))*y);
        sphere { v0 0.015625 }

        #local DStore[pC] = v0;

        #local pC = pC + 1;
    #end
    }
    #local layercount = layercount + 1;
#end
#debug concat("pC: " str(pC,0,0) "\n")
#debug concat("layers: " str(layercount,0,0) "\n")
#local header = ply_header("ascii", 1.0, "Anthony D. Baye", "A twisted ed
hexagonal column", pC)
#fopen pCloudFile "pointCloud2.ply" write
    #for(L,0,dimension_size(header,1)-1,1)
        #write(pCloudFile, header[L])
    #end
    #for(P,0,pC-1,1)
        #write(pCloudFile, vstr(3, DStore[P], " ",0,6), "\r\n")
    #end
#fclose pCloudFile

#for(A,0,360,60)
cylinder { R0*x, <R0, 10.0, 0.0> 0.015626 pigment { Orange } rotate A*y }
#end


Post a reply to this message

From: clipka
Subject: Re: #write
Date: 1 Mar 2016 05:03:15
Message: <56d568e3$1@news.povray.org>
Am 01.03.2016 um 07:20 schrieb Anthony D. Baye:

> Rebuilt using the latest master.  Bug's still there.
> remove the closing paren at line 180 and try rendering.  It gives me a segfault.

The Windows version is well-behaved:

Parse Error: Expected 'string', cylinder found instead

Did I ever mention that I hate it when the Windows version fails to
exhibit the same bugs as the Unix version?


Post a reply to this message

From: Le Forgeron
Subject: Re: #write
Date: 1 Mar 2016 17:08:49
Message: <56d612f1$1@news.povray.org>
Le 01/03/2016 11:03, clipka a écrit :
> Am 01.03.2016 um 07:20 schrieb Anthony D. Baye:
> 
>> Rebuilt using the latest master.  Bug's still there.
>> remove the closing paren at line 180 and try rendering.  It gives me a segfault.
> 
> The Windows version is well-behaved:
> 
> Parse Error: Expected 'string', cylinder found instead
> 
> Did I ever mention that I hate it when the Windows version fails to
> exhibit the same bugs as the Unix version?
> 

what is line 180 ?

from copy -paste of message, I go to

#local header = ply_header("ascii", 1.0, "Anthony D. Baye", "A twisted ed
hexagonal column", pC)

I presume text get folded and actually the line 180 is:

#write(pCloudFile, vstr(3, DStore[P], " ",0,6), "\r\n")

The segfault is due to a recursive parsing.... consumming 16321 function calls before
giving the problem.

(gdb) where
#0  __GI_____strtod_l_internal (nptr=nptr@entry=0x7f1dfedff3b0 "3",
endptr=endptr@entry=0x7f1dfedff5e8, group=group@entry=0, loc=0x7f1e06a5c500
<_nl_global_locale>) at strtod_l.c:498
#1  0x00007f1e066d2b30 in __GI___strtod_internal (nptr=nptr@entry=0x7f1dfedff3b0 "3",
endptr=endptr@entry=0x7f1dfedff5e8, group=group@entry=0) at strtod.c:54
#2  0x00007f1e066f2fe8 in _IO_vfscanf_internal (s=s@entry=0x7f1dfedff7a0,
format=format@entry=0x6f33a7 "%lf", argptr=argptr@entry=0x7f1dfedff8c8,
errp=errp@entry=0x0) at vfscanf.c:2326
#3  0x00007f1e067085e7 in _IO_vsscanf (string=0x7f1df000535c "3", format=0x6f33a7
"%lf", args=args@entry=0x7f1dfedff8c8) at iovsscanf.c:44
#4  0x00007f1e06702d17 in __sscanf (s=<optimized out>, format=format@entry=0x6f33a7
"%lf") at sscanf.c:32
#5  0x000000000065addc in pov::Parser::Read_Float (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:1237
#6  0x000000000065d6bc in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:570
#7  0x000000000064a29f in pov::Parser::Parse_Num_Factor
(this=this@entry=0x7f1df0004b80, Express=..., Terms=Terms@entry=0x7f1dfedffe3c) at
parser/parser_expressions.cpp:677
#8  0x000000000064c568 in pov::Parser::Parse_Num_Term (this=this@entry=0x7f1df0004b80,
Express=..., Terms=Terms@entry=0x7f1dfedffe3c) at parser/parser_expressions.cpp:1590
#9  0x000000000064cab8 in pov::Parser::Parse_Rel_Factor (this=0x7f1df0004b80,
Express=..., Terms=0x7f1dfedffe3c) at parser/parser_expressions.cpp:1663
#10 0x000000000064dec3 in pov::Parser::Parse_Float (this=this@entry=0x7f1df0004b80) at
parser/parser_expressions.cpp:2049
#11 0x0000000000665996 in pov::Parser::Parse_VStr (this=this@entry=0x7f1df0004b80,
pathname=<optimized out>) at parser/parser_strings.cpp:311
#12 0x000000000066552d in pov::Parser::Parse_String (this=this@entry=0x7f1df0004b80,
pathname=pathname@entry=false, require=require@entry=true) at
parser/parser_strings.cpp:154
#13 0x0000000000665855 in pov::Parser::Parse_C_String (this=this@entry=0x7f1df0004b80,
pathname=pathname@entry=false) at parser/parser_strings.cpp:110
#14 0x0000000000660fe9 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:3816
#15 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#16 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:451
#17 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:3753
#18 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#19 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:451
#20 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:3753
#21 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#22 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:451
#23 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:3753
#24 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#25 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:451
#26 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80) at
parser/parser_tokenizer.cpp:3753
....
....
#16307 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80)
at parser/parser_tokenizer.cpp:3753
#16308 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#16309 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80)
at parser/parser_tokenizer.cpp:451
#16310 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80)
at parser/parser_tokenizer.cpp:3753
#16311 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#16312 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80)
at parser/parser_tokenizer.cpp:451
#16313 0x0000000000660ef0 in pov::Parser::Parse_Write (this=this@entry=0x7f1df0004b80)
at parser/parser_tokenizer.cpp:3753
#16314 0x00000000006626ac in pov::Parser::Parse_Directive
(this=this@entry=0x7f1df0004b80, After_Hash=After_Hash@entry=1) at
parser/parser_tokenizer.cpp:2415
#16315 0x000000000065db3d in pov::Parser::Get_Token (this=this@entry=0x7f1df0004b80)
at parser/parser_tokenizer.cpp:451
#16316 0x0000000000557fd8 in pov::Parser::Parse_Frame (this=0x7f1df0004b80) at
parser/parser.cpp:6728
#16317 0x0000000000558b64 in pov::Parser::Run (this=0x7f1df0004b80) at
parser/parser.cpp:210
#16318 0x00000000005875df in pov::Task::TaskThread (this=0x7f1df0004b80,
completion=...) at backend/support/task.cpp:169
#16319 0x00007f1e0751a801 in thread_proxy () from
/usr/local/lib/libboost_thread.so.1.58.0
#16320 0x00007f1e0824a6aa in start_thread (arg=0x7f1dfeffe700) at pthread_create.c:333
#16321 0x00007f1e0679de9d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109


The heap is exhausted, and I would say that due to compilation option there is no
check to expand it further at each function call, hence the problem.
pC: 38520
layers: 321

We only need to have a bigger heap (38520 iterations... stacked 16300 call so far, for
about 8150 write, a x6 or x5 would allow to survive too) I guess that's what happening
for Windows, could be interesting to monitor its heap size as parser progress.

NAAAAHHH, Parse_Write should use a pattern already use elsewhere, no more than one
recursion... or even none at all.

ab-using code like
#write( .... #write( ...
is a call for lightning from Zeus and the opening of the multidimensional portal for
Chtulhu. The first to kill the abuser wins. In case of tie, Poseidon can make the life
of perpetrator an hell to which the saga of Ulysse would look like a pleasant walk on
Sunday afternoon.


Post a reply to this message

From: clipka
Subject: Re: #write
Date: 2 Mar 2016 02:25:33
Message: <56d6956d$1@news.povray.org>
Am 01.03.2016 um 23:08 schrieb Le_Forgeron:

> The heap is exhausted

I presume you mean "stack", right?

> NAAAAHHH, Parse_Write should use a pattern already use elsewhere, no more than one
recursion... or even none at all.

That would plug up only one of a guesstimated 4711 ways to coax the
POV-Ray parser into recursive calls.

Wanna bet that "#write" does the very same thing?

I think it would be more sensible to impose some arbitrary upper limit
to the nesting of Get_Token() calls; that would at least catch one
entire family of those 4711 ways.


Post a reply to this message

Goto Latest 10 Messages Next 9 Messages >>>

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