Cycles: Divide by zero with sky texture #83185

Closed
opened 2020-11-29 14:37:29 +01:00 by Robert Guetzkow · 11 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.30

Blender Version
Broken: version: 2.92.0 Alpha, branch: master, commit date: 2020-11-29 08:04, hash: 13c820d87b
Worked: -

Short description of error
Using a Sky Texture node for the world background results in a divide by zero in background_cdf (light.cpp ), because cdf_total is zero.

Exact steps for others to reproduce the error

  • Start Blender with a debugger attached. Set a breakpoint on the line float cdf_total_inv = 1.0f / cdf_total; with the condition set to cdf_total == 0.0f.
  • Set the render engine to Cycles.
  • In the shader editor for the world, add a Sky Texture node and connect it to the Background node.
  • Set viewport shading to Rendered.

or

  • Start Blender with a debugger attached. Set a breakpoint on the line float cdf_total_inv = 1.0f / cdf_total; with the condition set to cdf_total == 0.0f.
  • Open attached file.

Set viewport shading to Rendered.

2020-11-29-sky-texture-div-by-zero.blend

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1080 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 457.30 **Blender Version** Broken: version: 2.92.0 Alpha, branch: master, commit date: 2020-11-29 08:04, hash: `13c820d87b` Worked: - **Short description of error** Using a *Sky Texture* node for the world background results in a divide by zero in `background_cdf` ([light.cpp ](https://developer.blender.org/diffusion/B/browse/master/intern/cycles/render/light.cpp)), because `cdf_total` is zero. **Exact steps for others to reproduce the error** - Start Blender with a debugger attached. Set a breakpoint on the line `float cdf_total_inv = 1.0f / cdf_total;` with the condition set to `cdf_total == 0.0f`. - Set the render engine to Cycles. - In the shader editor for the world, add a *Sky Texture* node and connect it to the *Background* node. - Set viewport shading to *Rendered*. or - Start Blender with a debugger attached. Set a breakpoint on the line `float cdf_total_inv = 1.0f / cdf_total;` with the condition set to `cdf_total == 0.0f`. - Open attached file. # Set viewport shading to *Rendered*. [2020-11-29-sky-texture-div-by-zero.blend](https://archive.blender.org/developer/F9407680/2020-11-29-sky-texture-div-by-zero.blend)
Author
Member

Added subscriber: @rjg

Added subscriber: @rjg
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

Added subscriber: @brecht

Added subscriber: @brecht
Author
Member

@brecht I'm setting this to high priority since this causes undefined behavior and could lead to a crash.

@brecht I'm setting this to high priority since this causes undefined behavior and could lead to a crash.
Member

Added subscriber: @nacioss

Added subscriber: @nacioss

Float division by zero is not undefined behavior, it's well defined that the result is inf in this case. If it causes a crashes or other actual bug it might be high priority, but it's not clear to me from the report.

Float division by zero is not undefined behavior, it's well defined that the result is `inf` in this case. If it causes a crashes or other actual bug it might be high priority, but it's not clear to me from the report.

The division by zero is harmless in this case, but the code can be tweaked a bit for clarity by moving it inside the if (cdf_total > 0.0f) test.

The division by zero is harmless in this case, but the code can be tweaked a bit for clarity by moving it inside the ` if (cdf_total > 0.0f)` test.
Author
Member

@brecht My bad, seems like the version of UBSan I'm using is being overly cautious as theoretically some compiler might not implement Annex F. GCC and CLANG have the expected IEEE-754 behavior.

See discussion in:
https://bugs.llvm.org/show_bug.cgi?id=19535
https://stackoverflow.com/a/51487703

@brecht My bad, seems like the version of UBSan I'm using is being overly cautious as theoretically some compiler might not implement Annex F. GCC and CLANG have the expected IEEE-754 behavior. See discussion in: https://bugs.llvm.org/show_bug.cgi?id=19535 https://stackoverflow.com/a/51487703
Author
Member

@brecht Does it make sense to add the check in this case then? Technically, it could cause undefined behavior for compilers that don't implement Annex F / IEEE-754, not sure if that is actually the case for any compilers that are used today.

@brecht Does it make sense to add the check in this case then? Technically, it could cause undefined behavior for compilers that don't implement Annex F / IEEE-754, not sure if that is actually the case for any compilers that are used today.

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Brecht Van Lommel self-assigned this 2020-11-30 13:42:20 +01:00

Solved in c986e46.

Solved in c986e46.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#83185
No description provided.