FS#69951 - [blender] segfault when enabling OSL shading

Attached to Project: Community Packages
Opened by Paul Melis (paulmelis) - Friday, 12 March 2021, 10:01 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Wednesday, 21 April 2021, 05:29 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Sven-Hendrik Haase (Svenstaro)
Filipe Laíns (FFY00)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Enabling Open Shading Language shading when doing Cycles CPU rendering immediately segfaults when doing any rendering, regardless of the 3D scene.

{{{
melis@juggle 10:48:~$ cat /tmp/blender.crash.txt
# Blender 2.92.0, Commit date: 2021-02-24 16:25, Hash 02948a2cab44
bpy.context.space_data.context = 'RENDER' # Property
bpy.context.scene.render.engine = 'CYCLES' # Property
bpy.context.scene.cycles.shading_system = True # Property

# backtrace
blender(BLI_system_backtrace+0x34) [0x55e74ad0b084]
blender(+0xe151bd) [0x55e7487e21bd]
/usr/lib/libc.so.6(+0x3cf80) [0x7f652c953f80]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt9LLVM_Util13call_functionEPN4llvm5ValueEN16OpenImageIO_v2_24spanIKS4_Lln1EEE+0x160) [0x7f65334d30d0]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt16llvm_gen_closureERNS0_11BackendLLVMEi+0x2f5) [0x7f65334ab215]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt11BackendLLVM15build_llvm_codeEiiPN4llvm10BasicBlockE+0x196) [0x7f65334c37b6]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt11BackendLLVM19build_llvm_instanceEb+0xab6) [0x7f65334c6c36]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt11BackendLLVM3runEv+0x6ba) [0x7f65334c870a]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt17ShadingSystemImpl14optimize_groupERNS_11ShaderGroupEPNS_14ShadingContextEb+0x4cd) [0x7f653337190d]
/usr/lib/liboslexec.so.1.11(_ZN9OSL_v1_113pvt17ShadingSystemImpl19optimize_all_groupsEiiib+0x6ab) [0x7f653337489b]
/usr/lib/libstdc++.so.6(+0xcfbc4) [0x7f652ccf8bc4]
/usr/lib/libpthread.so.0(+0x9299) [0x7f65361f2299]
/usr/lib/libc.so.6(clone+0x43) [0x7f652ca16053]

# Python backtrace
}}}

GDB backtrace:
{{{
melis@juggle 10:50:~$ gdb `which blender`
GNU gdb (GDB) 10.1
...
Thread 24 "blender" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fff9c9ff640 (LWP 6594)]
0x00007ffff4f550d0 in OSL_v1_11::pvt::LLVM_Util::call_function(llvm::Value*, OpenImageIO_v2_2::span<llvm::Value* const, -1l>) () from /usr/lib/liboslexec.so.1.11
(gdb) bt
#0 0x00007ffff4f550d0 in OSL_v1_11::pvt::LLVM_Util::call_function(llvm::Value*, OpenImageIO_v2_2::span<llvm::Value* const, -1l>) () from /usr/lib/liboslexec.so.1.11
#1 0x00007ffff4f2d215 in OSL_v1_11::pvt::llvm_gen_closure(OSL_v1_11::pvt::BackendLLVM&, int) () from /usr/lib/liboslexec.so.1.11
#2 0x00007ffff4f457b6 in OSL_v1_11::pvt::BackendLLVM::build_llvm_code(int, int, llvm::BasicBlock*) () from /usr/lib/liboslexec.so.1.11
#3 0x00007ffff4f48c36 in OSL_v1_11::pvt::BackendLLVM::build_llvm_instance(bool) () from /usr/lib/liboslexec.so.1.11
#4 0x00007ffff4f4a70a in OSL_v1_11::pvt::BackendLLVM::run() () from /usr/lib/liboslexec.so.1.11
#5 0x00007ffff4df390d in OSL_v1_11::pvt::ShadingSystemImpl::optimize_group(OSL_v1_11::ShaderGroup&, OSL_v1_11::ShadingContext*, bool) () from /usr/lib/liboslexec.so.1.11
#6 0x00007ffff4df689b in OSL_v1_11::pvt::ShadingSystemImpl::optimize_all_groups(int, int, int, bool) () from /usr/lib/liboslexec.so.1.11
#7 0x00007fffee77abc4 in std::execute_native_thread_routine (__p=0x7fffb8018de0) at /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80
#8 0x00007ffff7c74299 in start_thread () from /usr/lib/libpthread.so.0
#9 0x00007fffee498053 in clone () from /usr/lib/libc.so.6
}}}

Appears to be somewhere in LLVM. On the same system this segfault does not occur when using the official 2.92 binaries from blender.org, which links statically against LLVM.


Additional info:

melis@juggle 10:47:~$ pacman -Qi blender
Name : blender
Version : 17:2.92.0-1
Description : A fully integrated 3D graphics creation suite
Architecture : x86_64
URL : http://www.blender.org
Licenses : GPL
Groups : None
Provides : None
Depends On : libpng libtiff openexr python desktop-file-utils python-requests potrace shared-mime-info hicolor-icon-theme xdg-utils glew openjpeg2 python-numpy freetype2 openal ffmpeg fftw boost-libs opencollada
alembic openxr openimageio libsndfile jack opencolorio1 openshadinglanguage openimagedenoise jemalloc libspnav ptex opensubdiv openvdb log4cplus sdl2 embree
Optional Deps : cuda: cycles renderer cuda support [installed]
Required By : None
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 300.54 MiB
Packager : Sven-Hendrik Haase <svenstaro@gmail.com>
Build Date : Thu 25 Feb 2021 10:24:05 PM CET
Install Date : Mon 01 Mar 2021 10:40:28 AM CET
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature


Steps to reproduce:

1. Start blender
2. Switch the renderer to Cycles (Render properties tab, set Render Engine to Cycles), Device to CPU
3. Enable Open Shading Language (just below the Device dropdown)
4. Press F12 to render
5. Segfault
This task depends upon

Closed by  Sven-Hendrik Haase (Svenstaro)
Wednesday, 21 April 2021, 05:29 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in openshadinglanguage-1.11.13.0-2
Comment by Sven-Hendrik Haase (Svenstaro) - Saturday, 13 March 2021, 10:36 GMT
What's your CPU?
Comment by Paul Melis (paulmelis) - Saturday, 13 March 2021, 17:04 GMT
Intel(R) Core(TM) i5-4460

Any specific feature you're looking for?
Comment by Sven-Hendrik Haase (Svenstaro) - Sunday, 14 March 2021, 03:40 GMT
Can reproduce. No idea when that broke. Perhaps it's due to our comparatively more recent version of OSL?
Comment by jean noel (jean_no) - Tuesday, 20 April 2021, 09:30 GMT
Hello,
A patch has just been released for OSL and LLVM 11 (by brechtvl a blender developer)
Links : https://github.com/AcademySoftwareFoundation/OpenShadingLanguage/pull/1361/files
and
https://git.blender.org/gitweb/gitweb.cgi/blender.git/blobdiff/c75b2019e101c498ccf65442ed262596639ee8bc..33f218fa3f93a3d574d81d65628188921d6f100c:/build_files/build_environment/patches/osl.diff

I patched OSL 1.11.13.0 and I don't have any crash anymore. Tested versions of blender : 2.92.0 , 2.93.0 beta and 3.0.0 alpha
Comment by Sven-Hendrik Haase (Svenstaro) - Wednesday, 21 April 2021, 05:28 GMT
Cool, confirming that it doesn't crash anymore with the patch, thanks for the heads-up! Pushing fixed OSL.

Loading...