POV-Ray : Newsgroups : povray.beta-test : Spline causing 3.8 beta 2 to crash Server Time
18 Mar 2024 22:41:24 EDT (-0400)
  Spline causing 3.8 beta 2 to crash (Message 1 to 10 of 22)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Chris R
Subject: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 09:50:00
Message: <web.63e3b5ca554275b637a9ec105cc1b6e@news.povray.org>
I have been experiencing crashes running the latest beta of POV-Ray v3.8 (Win64)
when trying to call a spline.  The narrowed it down to a few lines of code that
causes the crash:

#macro make_spline()
    #local _s   = spline {
        quadratic_spline
        0, <0, 0, 0>,
        1, <0, 0, 1>,
        2, <1, 0, 2>,
        3, <2, 1, 3>
    }
    _s
#end

#local myspline = spline { make_spline() }

#debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")

The contents of the spline don't seem to matter nor does the type of spline.
The result is a memory access violation.

When I run the same code on v3.7 it works fine.

Declaring the spline outside of a macro does not cause the crash:

#local myspline   = spline {
    natural_spline
    0, <0, 0, 0>,
    1, <0, 0, 1>,
    2, <1, 0, 2>,
    3, <2, 1, 3>
}

#debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")

-- Chris R.


Post a reply to this message

From: Chris R
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 09:55:00
Message: <web.63e3b7a9dd6df1a937a9ec105cc1b6e@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:
> I have been experiencing crashes running the latest beta of POV-Ray v3.8 (Win64)
> when trying to call a spline.  The narrowed it down to a few lines of code that
> causes the crash:
>
> #macro make_spline()
>     #local _s   = spline {
>         quadratic_spline
>         0, <0, 0, 0>,
>         1, <0, 0, 1>,
>         2, <1, 0, 2>,
>         3, <2, 1, 3>
>     }
>     _s
> #end
>
> #local myspline = spline { make_spline() }
>
> #debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")
>
> The contents of the spline don't seem to matter nor does the type of spline.
> The result is a memory access violation.
>
> When I run the same code on v3.7 it works fine.
>
> Declaring the spline outside of a macro does not cause the crash:
>
> #local myspline   = spline {
>     natural_spline
>     0, <0, 0, 0>,
>     1, <0, 0, 1>,
>     2, <1, 0, 2>,
>     3, <2, 1, 3>
> }
>
> #debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")
>
> -- Chris R.

One last observation, the following code also seems to work fine.  This leads me
to believe the problem lies with returning the spline identifier from the macro
and then trying to use it.  It's a kludgy work-around, but I can use it to
continue on my current project.

#macro make_spline_macro()
#declare myspline = spline {
   natural_spline
   0, <0, 0, 0>,
   1, <0, 0, 1>,
   2, <1, 0, 2>,
   3, <2, 1, 3>
}
#end

make_spline_macro()

#debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")


-- Chris R.


Post a reply to this message

From: jr
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 10:15:00
Message: <web.63e3bc55dd6df1a988a828ca6cde94f1@news.povray.org>
hi,

"Chris R" <car### [at] comcastnet> wrote:
> I have been experiencing crashes running the latest beta of POV-Ray v3.8 (Win64)
> when trying to call a spline.  The narrowed it down to a few lines of code that
> causes the crash:
>
> #macro make_spline()
>     #local _s   = spline {
>         quadratic_spline
>         0, <0, 0, 0>,
>         1, <0, 0, 1>,
>         2, <1, 0, 2>,
>         3, <2, 1, 3>
>     }
>     _s
> #end
>
> #local myspline = spline { make_spline() }
>
> #debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")
>
> The contents of the spline don't seem to matter nor does the type of spline.
> The result is a memory access violation.

my self compiled beta.2 (Linux) too crashes, same error I think.  the
alpha.9945627 outputs the 'pt_' ok.

changing the macro to

#macro make_spline()
    spline {
        quadratic_spline
        0, <0, 0, 0>,
        1, <0, 0, 1>,
        2, <1, 0, 2>,
        3, <2, 1, 3>
    }
#end

gives me 'Parse Error: Spline must have at least one entry.', and no crash.


regards, jr.


Post a reply to this message

From: jr
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 10:25:00
Message: <web.63e3bdcddd6df1a988a828ca6cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...
> changing the macro to
>
> #macro make_spline()
>     spline {
>         quadratic_spline
>         0, <0, 0, 0>,
>         1, <0, 0, 1>,
>         2, <1, 0, 2>,
>         3, <2, 1, 3>
>     }
> #end
>

and then writing

#declare myspline = make_spline();

appears to work, though.


regards, jr.


Post a reply to this message

From: Kenneth
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 13:15:00
Message: <web.63e3e608dd6df1a99b4924336e066e29@news.povray.org>
"Chris R" <car### [at] comcastnet> wrote:
> ..narrowed it down to a few lines of code that
> causes the crash:
>
> #macro make_spline()
>     #local _s   = spline {
>         quadratic_spline
>         0, <0, 0, 0>,
>         1, <0, 0, 1>,
>         2, <1, 0, 2>,
>         3, <2, 1, 3>
>     }
>     _s
> #end
>

I find that the above by itself runs OK in Windows 10, no fatal error. (I'm
running v3.8.0 beta 1, but I don't expect beta 2 to be much different.)

However, adding your #debug line causes the memory access violation.


Post a reply to this message

From: Kenneth
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 14:00:00
Message: <web.63e3f106dd6df1a99b4924336e066e29@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
>
> I find that the above by itself runs OK in Windows 10, no fatal error.

Sorry, I meant to include your #local myspline too. The following still runs OK.

#macro make_spline()
    #local _s   = spline {
        quadratic_spline
        0, <0, 0, 0>,
        1, <0, 0, 1>,
        2, <1, 0, 2>,
        3, <2, 1, 3>
    }
    _s
#end

#local myspline = spline { make_spline() }
>
> However, adding your #debug line causes the memory access violation.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 8 Feb 2023 21:01:11
Message: <63e453e7$1@news.povray.org>
On 2023-02-08 10:54 (-4), Chris R wrote:
> "Chris R" <car### [at] comcastnet> wrote:
>> I have been experiencing crashes running the latest beta of POV-Ray v3.8 (Win64)
>> when trying to call a spline.  The narrowed it down to a few lines of code that
>> causes the crash:
>>
>> [snip]

Confirmed on GNU/Linux.  V3.8 beta 2 yields a seg fault.  All other
versions I have beyond 3.1.0.10, including the master branch, UberPOV,
and the discontinued v3.7.1-RC1, yield "std::bad_alloc".  My oldest
UberPOV is 1.37.1.0-b10.

> One last observation, the following code also seems to work fine.  This leads me
> to believe the problem lies with returning the spline identifier from the macro
> and then trying to use it.  It's a kludgy work-around, but I can use it to
> continue on my current project.
> 
> #macro make_spline_macro()
> #declare myspline = spline {
>    natural_spline
>    0, <0, 0, 0>,
>    1, <0, 0, 1>,
>    2, <1, 0, 2>,
>    3, <2, 1, 3>
> }
> #end
> 
> make_spline_macro()
> 
> #debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")

This non-kludgy workaround also works:

#macro make_spline()
    spline {
        quadratic_spline
        0, <0, 0, 0>,
        1, <0, 0, 1>,
        2, <1, 0, 2>,
        3, <2, 1, 3>
    }
#end

#local myspline = make_spline()

#debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")


Post a reply to this message

From: Kenneth
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 9 Feb 2023 05:05:00
Message: <web.63e4c4a3dd6df1a99b4924336e066e29@news.povray.org>
Just discovered that your full original code example (WITH #debug) works OK, if
the #local inside the macro is changed to #declare. Why that should matter, I
don't know.

#macro make_spline()
    #declare _s   = spline {
        quadratic_spline
        0, <0, 0, 0>,
        1, <0, 0, 1>,
        2, <1, 0, 2>,
        3, <2, 1, 3>
    }
    _s
#end

#local myspline = spline { make_spline() }

#debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")


Post a reply to this message

From: William F Pokorny
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 9 Feb 2023 07:39:38
Message: <63e4e98a$1@news.povray.org>
On 2/9/23 05:02, Kenneth wrote:
> Just discovered that your full original code example (WITH #debug) works OK, if
> the #local inside the macro is changed to #declare. Why that should matter, I
> don't know.
> 
> #macro make_spline()
>      #declare _s   = spline {
>          quadratic_spline
>          0, <0, 0, 0>,
>          1, <0, 0, 1>,
>          2, <1, 0, 2>,
>          3, <2, 1, 3>
>      }
>      _s
> #end
> 
> #local myspline = spline { make_spline() }
> 
> #debug concat("_pt=<", vstr(3, myspline(0), ",", 0, 3), ">\n")
> 

The debugging you all have done has been helpful to me. Thanks!

Short on time but, I think we are seeing two different failure 
mechanisms, the second being tangled in the fix for Ingo's spline issue 
from July 2021. Ref:

http://news.povray.org/povray.beta-test/thread/%3CXnsAD687938A665Aseed7%40news.povray.org%3E/

Message: <XnsAD687938A665Aseed7@news.povray.org>

Running my povr branch with the final form of the fix using a clone 
method suggested by Christoph over my original code, I get the 
segmentation fault seen by many of you in newer official POV-Ray code. I 
have traced the segfault to this bit in parser_expressions.cpp:


     if (!New)
     {
         if (Old)
         {
             // Note. v3.7/v3.8 was always: New = new LinearSpline(*Old);
             New = Old->Clone(); // <-- Segfault with Clone method.

If I revert to the previous & incorrect code of:

           New = new LinearSpline(*Old);

I then see:

Parse Error:
std::bad_array_new_length

which is perhaps a different signature for the same bug, but I've not 
had time to dig into it.

Also not looked yet at the v3.7 stable code. The parser changed somewhat 
significantly after v3.7 as many know.

What I suspect off the top of my head is more recent parser code is 
dumping the macro defined #local spline where it should not. The first 
question is why and have a thought or two(a).

(a) For example, wondering about the new macro caching mechanism and 
whether it makes the macro 'look' like it's in another ram file with 
respect to #local ID / spline content persistence.

Bill P.


Post a reply to this message

From: Cousin Ricky
Subject: Re: Spline causing 3.8 beta 2 to crash
Date: 9 Feb 2023 14:09:23
Message: <63e544e3$1@news.povray.org>
On 2/9/23 06:02, Kenneth wrote:
> Just discovered that your full original code example (WITH #debug) works OK, if
> the #local inside the macro is changed to #declare. Why that should matter, I
> don't know.

A #local has to be declared in a temporary location, then released when
the macro returns.  This is opportunity for an allocation/de-allocation
mix-up that doesn't occur with #declare.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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