POV-Ray : Newsgroups : povray.general : return dictionary from macro [bug?] Server Time
22 Dec 2024 05:59:26 EST (-0500)
  return dictionary from macro [bug?] (Message 1 to 10 of 26)  
Goto Latest 10 Messages Next 10 Messages >>>
From: ingo
Subject: return dictionary from macro [bug?]
Date: 13 Apr 2021 13:17:04
Message: <XnsAD0BC42BCF8Aseed7@news.povray.org>
Not sure wether this was reported before.


//-----------
#version 3.8;

#macro SomeThing(A)
  #local RD = dictionary;
  RD
#end 
 
#declare SD = SomeThing(1);
//-----------

This crashes POV-Ray. Sometimes it asks to write a dump file.


//-----------
#version 3.8;

#macro SomeThing(A)
  #local RD = dictionary;
  (RD)
#end 
 
#declare SD = SomeThing(1);
//------------


This results in: test.pov" line 5: Parse Error: Expected 'numeric 
expression', dictionary
identifier found instead

Ingo


Post a reply to this message

From: jr
Subject: Re: return dictionary from macro [bug?]
Date: 13 Apr 2021 13:35:00
Message: <web.6075d5d9d2107a6c79819d986cde94f1@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> Not sure wether this was reported before.
>
> //-----------
> #version 3.8;
>
> #macro SomeThing(A)
>   #local RD = dictionary;
>   RD
> #end
>
> #declare SD = SomeThing(1);
> //-----------
>
> This crashes POV-Ray. Sometimes it asks to write a dump file.

here (unofficial alpha.10064268) it parses cleanly, with and without argument.
 can also assign key to 'SD'.  only warnings (assumed gamma, no objects).


> //-----------
> #version 3.8;
>
> #macro SomeThing(A)
>   #local RD = dictionary;
>   (RD)
> #end
>
> #declare SD = SomeThing(1);
> //------------
>
>
> This results in: test.pov" line 5: Parse Error: Expected 'numeric
> expression', dictionary
> identifier found instead

same here.


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: return dictionary from macro [bug?]
Date: 13 Apr 2021 14:03:03
Message: <XnsAD0BCBF287DC2seed7@news.povray.org>
in news:web.6075d5d9d2107a6c79819d986cde94f1@news.povray.org jr wrote:

 
> here (unofficial alpha.10064268) it parses cleanly, with and without
> argument. 
>  can also assign key to 'SD'.  only warnings (assumed gamma, no
>  objects). 
> 
> 

Should have added:
This is version 3.8.0-x.10064738+av694.msvc14.win64.
Win10.

Thanks jr, I'll step a version or so back tomorrow to test.

Ingo


Post a reply to this message

From: Thomas de Groot
Subject: Re: return dictionary from macro [bug?]
Date: 14 Apr 2021 02:21:27
Message: <607689e7$1@news.povray.org>
Op 13/04/2021 om 19:17 schreef ingo:
> Not sure wether this was reported before.
> 
> 
> //-----------
> #version 3.8;
> 
> #macro SomeThing(A)
>    #local RD = dictionary;
>    RD
> #end
>   
> #declare SD = SomeThing(1);
> //-----------
> 
> This crashes POV-Ray. Sometimes it asks to write a dump file.
> 
> 
> //-----------
> #version 3.8;
> 
> #macro SomeThing(A)
>    #local RD = dictionary;
>    (RD)
> #end
>   
> #declare SD = SomeThing(1);
> //------------
> 
> 
> This results in: test.pov" line 5: Parse Error: Expected 'numeric
> expression', dictionary
> identifier found instead
> 
> Ingo
> 

Using 3.8.0-alpha.10064268-+av691.msvc14w

First code works fine.
Second code crashes with identical parse error.

-- 
Thomas


Post a reply to this message

From: William F Pokorny
Subject: Re: return dictionary from macro [bug?]
Date: 14 Apr 2021 08:59:31
Message: <6076e733$1@news.povray.org>
On 4/13/21 1:17 PM, ingo wrote:
> Not sure wether this was reported before.
> 
> //-----------
> #version 3.8;
> 
> #macro SomeThing(A)
>    #local RD = dictionary;
>    RD
> #end
>   
> #declare SD = SomeThing(1);
> //-----------
> 

I'm confused as to what you are trying to do. Not myself used 
dictionaries much as yet, but it looks to me like you are after:

#macro SomeThing()
   dictionary
#end
#declare SD = SomeThing();

---
That said. Playing around with your original, first encoding I do see 
flaky segfaults which come and go in the povr branch that includes a set 
of v3.8 parser fixes necessary for other parser issues.

Thus far, the direct encoding above has never crashed. Neither has v3.8 
master at commit 74b3ebe0 for ANY variation of your encodings (ignoring 
the second (RD) one and less any heavy dictionary use).

I'll try and get together a debug build over the next few days - 
hopefully it crashes reliably enough I can run down the cause. I suspect 
something is going wrong with the identifier pointer handling when we 
get to the:

#declare SD = RD; // Effective action

Then depending on where the pointers point in memory and perhaps too the 
actual dictionary use, we crash or not - but, we shall see.

Bill P.


Post a reply to this message

From: ingo
Subject: Re: return dictionary from macro [bug?]
Date: 14 Apr 2021 13:44:20
Message: <XnsAD0CC8C65C6BAseed7@news.povray.org>
in news:6076e733$1@news.povray.org William F Pokorny wrote:

>> //-----------
>> #version 3.8;
>> 
>> #macro SomeThing(A)
>>    #local RD = dictionary;
>>    RD
>> #end
>>   
>> #declare SD = SomeThing(1);
>> //-----------
>> 
> 
> I'm confused as to what you are trying to do. Not myself used 
> dictionaries much as yet, but it looks to me like you are after:

The goal is to build a datastructure with the macro to pass around. After 
eliminating everything in the body of the macro this is what's left.

Haven't tried other versions of POV-Ray yet. Fiddling with something else. 
Will try soon as my old brain starts to remember discussing this with 
clipka before, .. I think.

Ingo


Post a reply to this message

From: William F Pokorny
Subject: Re: return dictionary from macro [bug?]
Date: 15 Apr 2021 11:59:02
Message: <607862c6$1@news.povray.org>
On 4/14/21 1:44 PM, ingo wrote:
> in news:6076e733$1@news.povray.org William F Pokorny wrote:
> 
>>> //-----------
>>> #version 3.8;
>>>
>>> #macro SomeThing(A)
>>>     #local RD = dictionary;
>>>     RD
>>> #end
>>>    
>>> #declare SD = SomeThing(1);
>>> //-----------
>>>
>>
>> I'm confused as to what you are trying to do. Not myself used
>> dictionaries much as yet, but it looks to me like you are after:
> 
> The goal is to build a datastructure with the macro to pass around. After
> eliminating everything in the body of the macro this is what's left.

Perhaps it would be simpler for the macro body to just be:

#macro...
dictionary {
...
}
#end

I do not see the reason for the local variable RD, though it 'should' 
always work - or always fail, if illegal to do.

> 
> Haven't tried other versions of POV-Ray yet. Fiddling with something else.
> Will try soon as my old brain starts to remember discussing this with
> clipka before, .. I think.
> 

Might not be worth your time. I think the land mine is sitting there 
with dictionaries no matter the version.

We can debug with simpler SDL. Further, if v3.8 master is compiled with 
POV_DEBUG set and the RD dictionary is set up with a few defaults, v3.8 
based version reliably trips a hard, debug, parser panic assertion.

This means there are at least a couple things wrong when doing 
assignments like #declare SD = RD; with dictionaries.

The original povr segfault (when I hit it) is during a pointer 
assignment during the parser clean up. The panic test which fails is 
couple lines below it, doing a reference>0 check. (Moving the test prior 
to the assignment doesn't roll up the segfault)

// ./configure COMPILED_BY="wfp" CXXFLAGS="-DPOV_DEBUG"
//-----------
#version 3.8;

// #local RD = dictionary;

    #local RD = dictionary {
        .foo: "this is nice.",
        .bar: 12345
    }

    #declare SD = RD;

    #error "Stop after parsing"
//-----------

Aside 1: the array code has special empty array handling, which doesn't 
exist for dictionaries. Perhaps it should...?

Near term. If using dictionaries, I'd recommend configuring and 
compiling with POV_DEBUG defined no matter the version - some protection 
in that.

Aside 2: The segfault and POV_DEBUG assertion is during parser clean up. 
However, I don't understand the related code well enough to know whether 
or not there might be situations where dictionaries might be 'running' 
OK, but not always behaving as they should. Users beware.

Unsure how long it might take me to unravel the dictionary parsing code 
well enough to understand the problems - let alone fix them...

Bill P.


Post a reply to this message

From: Kenneth
Subject: Re: return dictionary from macro [bug?]
Date: 16 Apr 2021 03:10:00
Message: <web.60793806d2107a6cd98418916e066e29@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:
> Not sure whether this was reported before.
>
> ...
>
> This crashes POV-Ray. Sometimes it asks to write a dump file.
>
> ...
>
> This results in: test.pov" line 5: Parse Error: Expected 'numeric
> expression', dictionary identifier found instead
>
> Should have added:
> This is version 3.8.0-x.10064738+av694.msvc14.win64.
> Win10.

Confirmed in both cases (running the same version in Win10).

William P's 'clean' code runs smoothly...
#macro SomeThing()
   dictionary
#end
#declare SD = SomeThing();

For what it's worth, this also runs OK...
#macro SomeThing(A)
   dictionary
#end
#declare SD = SomeThing(1);


Post a reply to this message

From: ingo
Subject: Re: return dictionary from macro [bug?]
Date: 16 Apr 2021 06:30:00
Message: <XnsAD0E7F27CB8B9seed7@news.povray.org>
in news:web.60793806d2107a6cd98418916e066e29@news.povray.org Kenneth 
wrote:

> Confirmed

Thanks


Post a reply to this message

From: William F Pokorny
Subject: Re: return dictionary from macro [bug?]
Date: 17 Apr 2021 08:09:41
Message: <607ad005$1@news.povray.org>
On 4/15/21 11:59 AM, William F Pokorny wrote:
> Aside 2: The segfault and POV_DEBUG assertion is during parser clean up. 
> However, I don't understand the related code well enough to know whether 
> or not there might be situations where dictionaries might be 'running' 
> OK, but not always behaving as they should. Users beware.
> 
> Unsure how long it might take me to unravel the dictionary parsing code 
> well enough to understand the problems - let alone fix them...

I believe I've run down the two issues to mistakes in a copy 
constructor. However, I need to test(1) with large dictionaries having 
key hashing collisions to be sure my fixes - as well the previously 
existing code - work correctly.

Posting immediately to confirm the previous code has the potential to 
"cross dictionaries" if you are using '#declare dic2 = dic1;' like 
encodings. Tangled and orphaned entries are possible.

(1) I suspect jr's recent foreach include work will come in handy! :-)

Bill P.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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