Crash rendering with OSL #42210

Closed
opened 2014-10-13 19:24:46 +02:00 by Shane Ambler · 7 comments

Changes to the ShaderClosure struct have bitten again, refer to previous bug #41123

I am now running FreeBSD 10.1 RC2, the same crash happens on 9.3 (only 64 bit tested)

To fix I applied the following

diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index ca1210f..637d024 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -553,7 +553,7 @@ typedef enum AttributeStandard {
 typedef struct ShaderClosure {
 	ClosureType type;
 	float3 weight;
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
 	float sample_weight;
 #endif
 	float data0;
@@ -562,7 +562,7 @@ typedef struct ShaderClosure {
 
 	float3 N;
 	float3 T;
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
 	float sample_weight;
 - endif
 - ifdef __OSL__

Does the location of sample_weight need to vary based on platform? or can all be the same.

For reference I am compiling blender (and almost everything) with clang 3.4.1, I have not had any luck building blender with OSL if most dependencies are built using gcc.

Changes to the ShaderClosure struct have bitten again, refer to previous bug #41123 I am now running FreeBSD 10.1 RC2, the same crash happens on 9.3 (only 64 bit tested) To fix I applied the following ``` diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index ca1210f..637d024 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -553,7 +553,7 @@ typedef enum AttributeStandard { typedef struct ShaderClosure { ClosureType type; float3 weight; -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__FreeBSD__) float sample_weight; #endif float data0; @@ -562,7 +562,7 @@ typedef struct ShaderClosure { float3 N; float3 T; -#ifdef __APPLE__ +#if defined(__APPLE__) || defined(__FreeBSD__) float sample_weight; - endif - ifdef __OSL__ ``` Does the location of sample_weight need to vary based on platform? or can all be the same. For reference I am compiling blender (and almost everything) with clang 3.4.1, I have not had any luck building blender with OSL if most dependencies are built using gcc.
Author

Changed status to: 'Open'

Changed status to: 'Open'
jens verwiebe was assigned by Shane Ambler 2014-10-13 19:24:46 +02:00
Author

Added subscriber: @sambler

Added subscriber: @sambler
jens verwiebe was unassigned by Sergey Sharybin 2014-10-14 09:41:35 +02:00
Sergey Sharybin self-assigned this 2014-10-14 09:41:35 +02:00

Added subscriber: @jensverwiebe

Added subscriber: @jensverwiebe

This issue requires much deeper investigation. I don't want the code to become more hairy in here, it's something wrong with wither alignment in cycles side and it might be some bugs in osl side as well.

This issue requires much deeper investigation. I don't want the code to become more hairy in here, it's something wrong with wither alignment in cycles side and it might be some bugs in osl side as well.

Ok, so now we know what's happening here. All that structure re-alignment are just red-herrings, doesn't fix anything and a dead-end to go for sure.

What's happening in fact is that CBSDFClosure and it's derivative classes uses ShaderClosure structure. Members of this structures are expected to be 16 bytes aligned when building kernel with SSE2 and above. What OSL does is it allocates the closures in a pool, totally ignoring alignment flags.

This makes some compiler assumptions to be wrong (i.e. for me it uses sse2 intrinsics to copy sc.N when flattening the graph. For sure this might easily lead to nasty crashes.

Proper solution would be to make sure our closure classes are 16 bytes aligned. This we can't do from our side, so i've send a pull-request to OSL folks: https://github.com/imageworks/OpenShadingLanguage/pull/428

Ok, so now we know what's happening here. All that structure re-alignment are just red-herrings, doesn't fix anything and a dead-end to go for sure. What's happening in fact is that `CBSDFClosure` and it's derivative classes uses `ShaderClosure` structure. Members of this structures are expected to be 16 bytes aligned when building kernel with SSE2 and above. What OSL does is it allocates the closures in a pool, totally ignoring alignment flags. This makes some compiler assumptions to be wrong (i.e. for me it uses sse2 intrinsics to copy `sc.N` when flattening the graph. For sure this might easily lead to nasty crashes. Proper solution would be to make sure our closure classes are 16 bytes aligned. This we can't do from our side, so i've send a pull-request to OSL folks: https://github.com/imageworks/OpenShadingLanguage/pull/428

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

I've committed a proper fix at 4cb0e25, the issue now should be gone.

Thanks for the report, closing it now.

I've committed a proper fix at 4cb0e25, the issue now should be gone. Thanks for the report, closing it now.
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
2 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#42210
No description provided.