Page MenuHome

Crash when trying to bake a texture from one model to another.
Confirmed, NormalPublic

Description

System Information
Operating system: Linux-5.4.0-45-generic-x86_64-with-debian-bullseye-sid 64 Bits
Graphics card: GeForce GTX 760/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.100

Blender Version
Broken: version: 2.90.0, branch: master, commit date: 2020-08-31 11:26, hash: rB0330d1af29c0
version 2.83 is broken as well

{F8833732}

Short description of error
When trying to bake a texture from one object to another, blender crashes.

Exact steps for others to reproduce the error
Open the attached .blend, select 'lier-scan' in the outliner, then ctrl-select 'remeshed'. Click bake. => crash.

Event Timeline

I compiled a debug version of v2.90.0 and created a backtrace:

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff77e0859 in __GI_abort () at abort.c:79
#2  0x00007ffff77e0729 in __assert_fail_base (fmt=0x7ffff7976588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0xfa66143 "index >= 0 && index < width", file=0xfa660e8 "blender/intern/cycles/kernel/../kernel/kernel_compat_cpu.h", line=77, function=<optimized out>) at assert.c:92
#3  0x00007ffff77f1f36 in __GI___assert_fail (assertion=0xfa66143 "index >= 0 && index < width", file=0xfa660e8 "blender/intern/cycles/kernel/../kernel/kernel_compat_cpu.h", line=77, function=0xfa68ab0 "const T& ccl::texture<T>::fetch(int) [with T = ccl::uint4]") at assert.c:101
#4  0x00000000069b4032 in ccl::texture<ccl::uint4>::fetch(int) (index=3974, this=0x7fffbae64d40) at blender/intern/cycles/kernel/../kernel/kernel_compat_cpu.h:77
#5  ccl::triangle_point_normal (shader=0x7fffbd3b3ee4, Ng=0x7fffbd3b55d0, P=0x7fffbd3b55c0, v=0.352764606, u=0.0591908991, prim=3974, object=0, kg=0x7fffbae64c20) at blender/intern/cycles/kernel/../kernel/geom/geom_triangle.h:48
#6  ccl::kernel_bake_evaluate(ccl::KernelGlobals*, float*, int, int, int, int, int) (kg=0x7fffbae64c20, buffer=0x7fffcb9e16e0, sample=0, x=576, y=384, offset=-25152, stride=64) at blender/intern/cycles/kernel/../kernel/kernel_bake.h:274
#7  0x00000000069bee1f in ccl::kernel_cpu_avx_bake(ccl::KernelGlobals*, float*, int, int, int, int, int) (kg=0x7fffbae64c20, buffer=0x7fffcb9e16e0, sample=0, x=576, y=384, offset=-25152, stride=64) at blender/intern/cycles/kernel/../kernel/kernels/cpu/kernel_cpu_impl.h:143
#8  0x0000000005ab9190 in ccl::CPUDevice::render(ccl::DeviceTask&, ccl::RenderTile&, ccl::KernelGlobals*) (this=0x7fffbeb99000, task=..., tile=..., kg=0x7fffbae64c20) at blender/intern/cycles/device/device_cpu.cpp:925
#9  0x0000000005abb2ff in ccl::CPUDevice::thread_render(ccl::DeviceTask&) (this=0x7fffbeb99000, task=...) at blender/intern/cycles/device/device_cpu.cpp:1252
#10 0x0000000005ab7681 in ccl::CPUDevice::thread_run(ccl::DeviceTask&) (this=0x7fffbeb99000, task=...) at blender/intern/cycles/device/device_cpu.cpp:529
#11 0x0000000005abbcc7 in ccl::CPUDevice::task_add(ccl::DeviceTask&)::{lambda()#1}::operator()() const (__closure=0x7fffbaef5000) at blender/intern/cycles/device/device_cpu.cpp:1408
#12 0x0000000005ac4564 in std::_Function_handler<void (), ccl::CPUDevice::task_add(ccl::DeviceTask&)::{lambda()#1}>::_M_invoke(std::_Any_data const&) (__functor=...) at /usr/include/c++/9/bits/std_function.h:300
#13 0x0000000004d61118 in std::function<void ()>::operator()() const (this=0x7fffbae3edc8) at /usr/include/c++/9/bits/std_function.h:688
#14 0x000000000b7e8f98 in tbb::internal::function_task<std::function<void ()> >::execute() (this=0x7fffbae3edc0) at lib/linux_centos7_x86_64/tbb/include/tbb/task.h:1048
#15 0x00000000036ccca5 in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::process_bypass_loop(tbb::internal::context_guard_helper<false>&, tbb::task*, long) ()
#16 0x00000000036ccf5b in tbb::internal::custom_scheduler<tbb::internal::IntelSchedulerTraits>::local_wait_for_all(tbb::task&, tbb::task*) ()
#17 0x00000000053d1aa5 in tbb::task::wait_for_all() (this=0x7fffbeb64cc0) at lib/linux_centos7_x86_64/tbb/include/tbb/task.h:809
#18 0x00000000053d8220 in tbb::internal::task_group_base::wait() (this=0x7fffbeb990a0) at lib/linux_centos7_x86_64/tbb/include/tbb/task_group.h:168
#19 0x000000000b7e6b26 in ccl::TaskPool::wait_work(ccl::TaskPool::Summary*) (this=0x7fffbeb990a0, stats=0x0) at blender/intern/cycles/util/util_task.cpp:44
#20 0x0000000005abc521 in ccl::CPUDevice::task_wait() (this=0x7fffbeb99000) at blender/intern/cycles/device/device_cpu.cpp:1415
#21 0x00000000081dde8d in ccl::Session::run_cpu() (this=0x7fffbea53100) at blender/intern/cycles/render/session.cpp:739
#22 0x00000000081dec2b in ccl::Session::run() (this=0x7fffbea53100) at blender/intern/cycles/render/session.cpp:876
#23 0x00000000081e5abe in std::__invoke_impl<void, void (ccl::Session::*&)(), ccl::Session*&>(std::__invoke_memfun_deref, void (ccl::Session::*&)(), ccl::Session*&) (__f=@0x7fffbeaa0cc0: (void (ccl::Session::*)(class ccl::Session * const)) 0x81deafa <ccl::Session::run()>, __t=@0x7fffbeaa0cd0: 0x7fffbea53100) at /usr/include/c++/9/bits/invoke.h:73
#24 0x00000000081e5273 in std::__invoke<void (ccl::Session::*&)(), ccl::Session*&>(void (ccl::Session::*&)(), ccl::Session*&) (__fn=@0x7fffbeaa0cc0: (void (ccl::Session::*)(class ccl::Session * const)) 0x81deafa <ccl::Session::run()>) at /usr/include/c++/9/bits/invoke.h:95
#25 0x00000000081e44af in std::_Bind<void (ccl::Session::*(ccl::Session*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) (this=0x7fffbeaa0cc0, __args=...) at /usr/include/c++/9/functional:400
#26 0x00000000081e35df in std::_Bind<void (ccl::Session::*(ccl::Session*))()>::operator()<, void>() (this=0x7fffbeaa0cc0) at /usr/include/c++/9/functional:484
#27 0x00000000081e2aa7 in std::_Function_handler<void (), std::_Bind<void (ccl::Session::*(ccl::Session*))()> >::_M_invoke(std::_Any_data const&) (__functor=...) at /usr/include/c++/9/bits/std_function.h:300
#28 0x0000000004d61118 in std::function<void ()>::operator()() const (this=0x7fffbeb6ef70) at /usr/include/c++/9/bits/std_function.h:688
#29 0x000000000b7e911e in ccl::thread::run(void*) (arg=0x7fffbeb6ef70) at blender/intern/cycles/util/util_thread.cpp:52
#30 0x000000000b7e98fc in std::__invoke_impl<void*, void* (*)(void*), ccl::thread*>(std::__invoke_other, void* (*&&)(void*), ccl::thread*&&) (__f=@0x7fffbeba9d70: 0xb7e90e0 <ccl::thread::run(void*)>) at /usr/include/c++/9/bits/invoke.h:60
#31 0x000000000b7e985d in std::__invoke<void* (*)(void*), ccl::thread*>(void* (*&&)(void*), ccl::thread*&&) (__fn=@0x7fffbeba9d70: 0xb7e90e0 <ccl::thread::run(void*)>) at /usr/include/c++/9/bits/invoke.h:95
#32 0x000000000b7e97bd in std::thread::_Invoker<std::tuple<void* (*)(void*), ccl::thread*> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) (this=0x7fffbeba9d68) at /usr/include/c++/9/thread:244
#33 0x000000000b7e9774 in std::thread::_Invoker<std::tuple<void* (*)(void*), ccl::thread*> >::operator()() (this=0x7fffbeba9d68) at /usr/include/c++/9/thread:251
#34 0x000000000b7e9754 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void* (*)(void*), ccl::thread*> > >::_M_run() (this=0x7fffbeba9d60) at /usr/include/c++/9/thread:195
#35 0x000000000e92cc24 in execute_native_thread_routine ()
#36 0x00007ffff7f49609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#37 0x00007ffff78dd103 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

I did some more digging with valgrind and found the following:

Valgrind output:

Thread 22:
Conditional jump or move depends on uninitialised value(s)
   at 0xC07C444: render_result_from_bake (external_engine.c:192)
   by 0xC07C868: RE_engine_begin_result (external_engine.c:263)
   by 0x3D51D02: RenderEngine_begin_result_func (rna_render_gen.c:1219)
   by 0x59FD587: BL::RenderEngine::begin_result(int, int, int, int, char const*, char const*) (RNA_blender_cpp.h:54567)
   by 0x59F745A: ccl::begin_render_result(BL::RenderEngine&, int, int, int, int, char const*, char const*) (blender_session.cpp:315)
   by 0x59F75E2: ccl::BlenderSession::do_write_update_render_tile(ccl::RenderTile&, bool, bool, bool) (blender_session.cpp:339)
   by 0x59F7A25: ccl::BlenderSession::read_render_tile(ccl::RenderTile&) (blender_session.cpp:394)
   by 0x5A044F4: void std::__invoke_impl<void, void (ccl::BlenderSession::*&)(ccl::RenderTile&), ccl::BlenderSession*&, ccl::RenderTile&>(std::__invoke_memfun_deref, void (ccl::BlenderSession::*&)(ccl::RenderTile&), ccl::BlenderSession*&, ccl::RenderTile&) (invoke.h:73)
   by 0x5A03E66: std::__invoke_result<void (ccl::BlenderSession::*&)(ccl::RenderTile&), ccl::BlenderSession*&, ccl::RenderTile&>::type std::__invoke<void (ccl::BlenderSession::*&)(ccl::RenderTile&), ccl::BlenderSession*&, ccl::RenderTile&>(void (ccl::BlenderSession::*&)(ccl::RenderTile&), ccl::BlenderSession*&, ccl::RenderTile&) (invoke.h:95)
   by 0x5A032FB: void std::_Bind<void (ccl::BlenderSession::*(ccl::BlenderSession*, std::_Placeholder<1>))(ccl::RenderTile&)>::__call<void, ccl::RenderTile&, 0ul, 1ul>(std::tuple<ccl::RenderTile&>&&, std::_Index_tuple<0ul, 1ul>) (functional:400)
   by 0x5A02251: void std::_Bind<void (ccl::BlenderSession::*(ccl::BlenderSession*, std::_Placeholder<1>))(ccl::RenderTile&)>::operator()<ccl::RenderTile&, void>(ccl::RenderTile&) (functional:484)
   by 0x5A00E19: std::_Function_handler<void (ccl::RenderTile&), std::_Bind<void (ccl::BlenderSession::*(ccl::BlenderSession*, std::_Placeholder<1>))(ccl::RenderTile&)> >::_M_invoke(std::_Any_data const&, ccl::RenderTile&) (std_function.h:300)

The offending line is in /source/blender/render/intern/source/external_engine.c :

192├> if (bake_pixel->object_id != engine->bake.object_id) {

If valgrind is to be believed, only the first 4 bytes of the memory bake_pixel points to are defined ( those would be bake_pixel->primitive_id, which is set to -1) and bake_pixel->object_id is undefined .

I'll see if I can find out where the undefined memory comes from, but as I'm very unfamiliar with the blender source code I'm not really sure what this means. I might even be completely harmless.

If I continue from this error I immediately end up in the crash from the above stacktrace. With index consistently set to 3974, but width seems to be filled with random data, because it is different on each run and I've even seen negative values for it.

I hope this extra info will help. If more testing/debugging needs to be done I can do more valgrind runs if somebody can tell me what to look for...

Ankit Meel (ankitm) changed the task status from Needs Triage to Confirmed.Mon, Sep 7, 10:06 PM

Thank you so much for debugging this out!
note to self to try to redo it.

Ankit Meel (ankitm) added a comment.EditedTue, Sep 8, 8:51 AM

A note that there's a circular dependency "Circular dependency for image "lier-model" from object "remeshed"" . It should be removed.

The circular dependency is (imho) a false positive. The image lier-model is attached to the remeshed base color image texture. But the color data is coming from lier-scan, which has a different material. Remeshed is the target object and it's texture is only written to. My guess is that the dependency checker ignores the 'selected to active' setting.

I always ignore this warning in this specific situation and it has never lead to problems. Furthermore, if I detach the image from the 'base color' slot, the warning goes away, but the crash stays (with exactly the same symptoms and tracebacks).

I found out that if I export 'lier-scan' and 'remeshed' to .obj files and I import them both in a clean .blend the problem goes away. So somehow something got messed up in this specific .blend and it's not the geometry/topology that's causing the crash.