POV-Ray / povray

The Persistence of Vision Raytracer: http://www.povray.org/
GNU Affero General Public License v3.0
1.35k stars 282 forks source link

[BUG] Parse error when using povray built by GCC 13, no error with GCC 12 #460

Open fgaz opened 3 months ago

fgaz commented 3 months ago

Summary

I get "Parse Error: Viewing angle has to be smaller than 180 degrees." when using povray built by GCC 13, no error with GCC 12

POV-Ray Version

Runtime Environment

Scene

You can find the scene files in the _pov directories here https://gitlab.com/roever/toppler/-/tree/main/datafile

To render them them:

I can try to extract a minimal reproducer if needed.

Command Line Options

You can find the ini files in the _pov directories here https://gitlab.com/roever/toppler/-/tree/main/datafile

Expected Behavior

The scene is rendered regardless of the GCC version used to compile povray

Actual Behavior

I get "Parse Error: Viewing angle has to be smaller than 180 degrees." when povray is built with GCC 13, no error when povray is built with GCC 12

Output

povray: cannot open the user configuration file /home/fgaz/.povray/3.8/povray.conf: No such file or directory
Persistence of Vision(tm) Ray Tracer Version 3.8.0-beta.2.unofficial (g++ 13.2.0
 @ x86_64-pc-linux-gnu)
This is an unofficial version compiled by:
 NixOS
 The POV-Ray Team is not responsible for supporting this version.

POV-Ray is based on DKBTrace 2.12 by David K. Buck & Aaron A. Collins
Copyright 1991-2021 Persistence of Vision Raytracer Pty. Ltd.

Primary POV-Ray v3.8 Architects/Developers: (Alphabetically)
  Chris Cason         Christoph Lipka   

With Assistance From: (Alphabetically)
  Jerome Grimbert     James Holsenback    William F. Pokorny

Past Contributors: (Alphabetically)
  Steve Anger         Eric Barish         Dieter Bayer        David K. Buck     
  Nicolas Calimet     Chris Cason         Aaron A. Collins    Chris Dailey      
  Steve Demlow        Andreas Dilger      Alexander Enzmann   Dan Farmer        
  Thorsten Froehlich  Mark Gordon         Jerome Grimbert     James Holsenback  
  Christoph Hormann   Mike Hough          Chris Huff          Kari Kivisalo     
  Nathan Kopp         Lutz Kretzschmar    Christoph Lipka     Jochen Lippert    
  Pascal Massimino    Jim McElhiney       Douglas Muir        Juha Nieminen     
  Ron Parker          William F. Pokorny  Bill Pulver         Eduard Schwan     
  Wlodzimierz Skiba   Robert Skinner      Yvo Smellenbergh    Zsolt Szalavari   
  Scott Taylor        Massimo Valentini   Timothy Wegner      Drew Wells        
  Chris Young       

Other contributors are listed in the documentation.

Support libraries used by POV-Ray:
  ZLib 1.3.1, Copyright 1995-2012 Jean-loup Gailly and Mark Adler
  LibPNG 1.6.43, Copyright 1998-2012 Glenn Randers-Pehrson
  LibJPEG 6b, Copyright 1991-2016 Thomas G. Lane, Guido Vollbeding
  LibTIFF 4.6.0, Copyright 1988-1997 Sam Leffler, 1991-1997 SGI
  Boost 1.81, http://www.boost.org/

Dynamic optimizations:
  CPU detected: AMD,FMA4
  Noise generator: generic (portable)

Rendering frame 1 of 240 (#0)

Rendering frame 1 of 240 (#0)

Parser Options
  Input file: cross.pov
  Remove bounds........On 
  Split unions.........Off
  Library paths:
    /nix/store/i71lnh23qqzjb7ir5brk7l8vf62lssp0-povray-3.8.0-beta.2/share/povray
-3.8
    /nix/store/i71lnh23qqzjb7ir5brk7l8vf62lssp0-povray-3.8.0-beta.2/share/povray
-3.8/ini
    /nix/store/i71lnh23qqzjb7ir5brk7l8vf62lssp0-povray-3.8.0-beta.2/share/povray
-3.8/include
    ../../datafile/cross_pov
Animation Options
  Initial Frame:        0  Final Frame:      239
  Frame Step:           1
  Initial Clock:    0.000  Final Clock:    2.000
  Cyclic Animation.....On   Field render.........Off  Odd lines/frames.....Off
Image Output Options
  Image resolution.....32 by 32 (rows 1 to 32, columns 1 to 32).
  Output file..........cross000.png, 24 bpp PNG
  Dithering............Off
  Graphic display......Off
  Mosaic preview.......Off
  Continued trace......Off
Information Output Options
  All Streams to console..........On 
  Debug Stream to console.........On 
  Fatal Stream to console.........On 
  Render Stream to console........On 
  Statistics Stream to console....On 
  Warning Stream to console.......On 
==== [Parsing...] ==========================================================
File '../sprites_pov/environment.pov' line 16: Parse Error: Viewing angle has to
 be smaller than 180 degrees.
Fatal error in parser: Cannot parse input.
Render failed

Additional context

Discovered in https://github.com/NixOS/nixpkgs/issues/311017

Workaround

Build povray with GCC 12.

Adding any angle to the camera also seems to work.

wfpokorny commented 3 months ago

I'm just another user - long with his own fork of v3.8, but I took a quick look at your scene files and the source.

I don't see that you are anywhere setting an angle in a camera block.

This leads me to wonder about HUGE_VAL, because - without running all the scenes with a compiler version I don't have handy - I don't see how we are getting into that conditional in .../source/parser/parser.cpp unless something is amiss with it.

The official releases of POV-Ray have since V1.0 carried around this bit - now in (.../source/core/configcore.h ):

#ifndef HUGE_VAL
    #define HUGE_VAL 1.0e+17
#endif

In my own fork I replaced that with:

#ifndef HUGE_VALF
    #error "HUGE_VALF is not defined in math.h/<cmath> and must be."
#endif
#ifndef HUGE_VAL
    #error "HUGE_VAL is not defined in math.h/<cmath> and must be."
#endif
#ifndef HUGE_VALL
    #error "HUGE_VALL is not defined in math.h/<cmath> and must be."
#endif

I wanted to be sure I was getting, c++11 or later, definitions from <cmath> and not some old POV-Ray definition. It might be worth trying the replacement checking code above to be sure you are not getting POV-Ray's old, old HUGE_VAL definition. One perhaps mixed in with a compiler provided definition...? A long shot I know.

Beyond that I am not sure... Suppose you could try compiling to particular c++ standards by setting those when you configure: ./configure -q COMPILED_BY="..." CXXFLAGS="-std=c++17" as you are perhaps defaulting to some newer standard. I usually run with c++17, but the POV-Ray source code compiles back to c++11.

wjeaton commented 2 months ago

The problem is caused by the gcc -ffast-math optimizations. This flag turns on -ffinite-math-only, which acts as a promise to the compiler that code will never use floating point infinities. HUGE_VAL get defined as +inf, often in math.h. Code in Parser::Parse_Camera does comparisons to HUGE_VAL, which the compiler treats as constant because of the above promise. Quick work-around: add add -fno-finite-math-only to CXXFLAGS during configuration. Also adding -DBOOST_BIND_GLOBAL_PLACEHOLDERS silences some Boost deprecation warnings.

Better fix: rename HUGE_VAL to HUGE_FINITE_VAL throughout the source, patches attached for 3.7 and 3.8 beta 2. fedora40patch.zip