Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when using CompareFloat with "new" CPUs. #5430

Closed
LinasBeres opened this issue Aug 22, 2023 · 3 comments
Closed

Crash when using CompareFloat with "new" CPUs. #5430

LinasBeres opened this issue Aug 22, 2023 · 3 comments

Comments

@LinasBeres
Copy link

Version: Gaffer 1.2.10.0-linux (e.g. 0.47.0.0-linux)
Third-party tools: None
Third-party modules: None

Description

This bug may be an OSL issue but right now I don't quite know how to decouple it from Gaffer and give the OSL guys something to debug. The test scene is very simple but it does only crash on certain CPUs. Note that setting GAFFEROSL_USE_BATCHED to 0 fixes this bug, which is why I am currently leaning on it being a OSL issue.

Fails on this CPU: Intel(R) Xeon(R) W-2145

Flags:

fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin intel_pt ssbd mba ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm mpx rdt_a avx512f avx512dq rdseed adx smap clflushopt clwb avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts hwp hwp_act_window hwp_epp hwp_pkg_req md_clear spec_ctrl intel_stibp flush_l1d

Replacing CompareFloat with custom OSL (which does the exact same thing) does not crash the scene.

Steps to reproduce

  1. Open the bellow graph (or create your own with CompareFloat node with inputs from a OSL node say output = time * 0.005 and then link to OSLImage or OSLObject)
  2. Focus OSLImage
  3. Crash

Debug log

Click to Expand


/dependencies-6.0.0-source/OpenShadingLanguage/working/OpenShadingLanguage-1.12.9.0/src/liboslexec/batched_backendllvm.cpp:1234: llvm_store_value: Assertion 'll.type_ptr(ll.llvm_typeof(new_val)) == ll.llvm_typeof(dst_ptr)' failed.
/dependencies-6.0.0-source/OpenShadingLanguage/working/OpenShadingLanguage-1.12.9.0/src/liboslexec/llvm_util.cpp:2958: native_to_llvm_mask: Assertion 'native_mask->getType() == type_native_mask()' failed.
/dependencies-6.0.0-source/OpenShadingLanguage/working/OpenShadingLanguage-1.12.9.0/src/liboslexec/llvm_util.cpp:5567: op_bool_to_float: Assertion '0 && "Op has bad value type combination"' failed.
WARNING | signal caught: SIGSEGV -- Invalid memory reference

Scene

import Gaffer
import GafferImage
import GafferOSL
import imath

__children = {}

__children["defaultFormat"] = GafferImage.FormatPlug( "defaultFormat", defaultValue = GafferImage.Format( 1920, 1080, 1.000 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, )
parent.addChild( __children["defaultFormat"] )
__children["CompareFloat"] = GafferOSL.OSLShader( "CompareFloat" )
parent.addChild( __children["CompareFloat"] )
__children["CompareFloat"].loadShader( "Utility/CompareFloat" )
__children["CompareFloat"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLCode1"] = GafferOSL.OSLCode( "OSLCode1" )
parent.addChild( __children["OSLCode1"] )
__children["OSLCode1"]["out"].addChild( Gaffer.FloatPlug( "output1", direction = Gaffer.Plug.Direction.Out, defaultValue = 0.0, flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLCode1"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["OSLImage"] = GafferOSL.OSLImage( "OSLImage" )
parent.addChild( __children["OSLImage"] )
__children["OSLImage"]["channels"].addChild( Gaffer.NameValuePlug( "", Gaffer.Color3fPlug( "value", defaultValue = imath.Color3f( 1, 1, 1 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ), True, "channel", Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
__children["OSLImage"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["CompareFloat"]["parameters"]["condition"].setValue( 5 )
__children["CompareFloat"]["parameters"]["a"].setInput( __children["OSLCode1"]["out"]["output1"] )
__children["CompareFloat"]["parameters"]["b"].setInput( __children["OSLCode1"]["out"]["output1"] )
__children["CompareFloat"]["__uiPosition"].setValue( imath.V2f( -45.5782013, 36.0690079 ) )
__children["OSLCode1"]["code"].setValue( 'output1 = time * 0.005;' )
__children["OSLImage"]["channels"]["channel"]["value"]["r"].setInput( __children["CompareFloat"]["out"]["success"] )
__children["OSLImage"]["__uiPosition"].setValue( imath.V2f( -7.29935026, 26.6614037 ) )


del __children
@LinasBeres
Copy link
Author

Does NOT crash on Intel(R) Xeon(R) CPU E5-1660 v4.

Flags:

fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb cat_l3 cdp_l3 invpcid_single intel_ppin intel_pt ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm cqm rdt_a rdseed adx smap xsaveopt cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local dtherm ida arat pln pts md_clear spec_ctrl intel_stibp flush_l1d

@johnhaddon
Copy link
Member

I've reproduced this without Gaffer involved, and reported it as a bug in the OSL project. Will open a PR with a workaround in Gaffer shortly.

@danieldresser-ie
Copy link
Contributor

This fix looks reasonable as a workaround - hopefully the underlying bug gets fixed quickly, but it will probably take us long enough to get on a new version that it still makes sense to merge this in the mean time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants