Page MenuHome

Linking an unused Light datablock to an existing light object crashes Blender.
Closed, ResolvedPublicBUG

Description

System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 430.86

Blender Version
Broken: version: 2.80 (sub 74), branch: master, commit date: 2019-05-31 22:45, hash: rBcc600de6695a
Worked: (optional)

Short description of error
If you create multiple lights, you can make them all linked so that changing properties of one of the instances will change all of the lights.
But if a light datablock is unlinked or deleted and then selected as the linked object, Blender will crash.

Exact steps for others to reproduce the error
First I startup Blender file and create a plane and adjust the object locations to see stuff better. Then I go to Rendered shading mode (I'm using Cycles).


Then I create 2 more lights by duplicating with Ctrl+D. I change the colours of the new lamps.

Now, just to show how things should (probably) work, I select the original lamp and in the object data properties menu, I select it to be linked to the blue lamp.

Lighting of the scene will not update until I move the changed lamp in the viewport or go to eg. solid shading mode and return to Cycles rendered shading mode.

If I now delete the lamp.002 and create a new lamp and try to link the newly created lamp with lamp.002 datablock, I've broken Blender. If I now move the brokenly linked lamp, Blender will crash.

In this last picture, we can observe that even though I deleted lamp.002, I can set the NEWLAMP object to be lamp.002. But as we can see, the light didn't change red as it should have. I then changed the shading mode to solid and returned back to Rendered shading mode and Blender crashed - but Blender will also crash if the lamp is moved.

Event Timeline

I can reproduce the crash! (Ubuntu 18.04.2, hwe kernel 4.18.0-25-generic, CPU i7-4800MQ, running on iGPU).

Here is /tmp/blender-crash.txt:

Blender 2.80 (sub 74), Commit date: 2019-07-04 12:18, Hash 2ee257e2c34f
bpy.context.space_data.context = 'RENDER' # Property
bpy.context.scene.render.engine = 'CYCLES' # Property
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(-0.900137, -2.78419, -0.605438), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), >"orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, >"use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, >"release_confirm":False, "use_accurate":False}) # Operator
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(-2.48568, -5.10081, 0.427437), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), >"orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, >"use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, >"release_confirm":False, "use_accurate":False}) # Operator
bpy.data.screens["Layout"].shading.type = 'RENDERED' # Property
bpy.context.space_data.context = 'DATA' # Property
bpy.ops.object.delete(use_global=False) # Operator
Deleted 1 object(s) # Info
bpy.ops.object.light_add(type='POINT', radius=1, location=(0, 0, 0)) # Operator
bpy.ops.transform.translate(value=(-4.21024, -3.87805, 4.58718), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', >proportional_size=1, use_proportional_connected=False, use_proportional_projected=False) # Operator
__
backtrace
./blender(BLI_system_backtrace+0x1d) [0x135f82d]
./blender() [0x1148199]
/lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f6403db8f20]
./blender(_ZN3ccl6Shader8tag_usedEPNS_5SceneE+0) [0x3d9fa40]
./blender(_ZN3ccl11BlenderSync11find_shaderERN2BL2IDERNS_6vectorIPNS_6ShaderENS_16GuardedAllocatorIS6_EEEES6_+0xed) [0x157de1d]
./blender(_ZN3ccl11BlenderSync10sync_lightERN2BL6ObjectEPiS3_S3_iRNS_9TransformEPb+0x77c) [0x155ee5c]
./blender(_ZN3ccl11BlenderSync11sync_objectERN2BL9DepsgraphERNS1_9ViewLayerERNS1_23DepsgraphObjectInstanceEfbbRNS_20BlenderObjectCullingEPb+0xc2a) [0x156025a]
./blender(_ZN3ccl11BlenderSync12sync_objectsERN2BL9DepsgraphEf+0x771) [0x1561ce1]
./blender(_ZN3ccl11BlenderSync9sync_dataERN2BL14RenderSettingsERNS1_9DepsgraphERNS1_11SpaceView3DERNS1_6ObjectEiiPPv+0x16a) [0x1552baa]
./blender(_ZN3ccl14BlenderSession11synchronizeERN2BL9DepsgraphE+0x648) [0x15472f8]
./blender() [0x153dc5d]
./blender(_PyMethodDef_RawFastCallKeywords+0x2b9) [0x17455a9]
./blender(_PyCFunction_FastCallKeywords+0x25) [0x1745665]
./blender(_PyEval_EvalFrameDefault+0x8d5f) [0x114425f]
./blender() [0x113a450]
./blender(_PyEval_EvalFrameDefault+0x79c3) [0x1142ec3]
./blender() [0x113a450]
./blender(_PyFunction_FastCallDict+0x2a6) [0x1745026]
./blender() [0x13dc2ee]
./blender() [0x14b0fe7]
./blender(ED_render_scene_update+0x1bb) [0x3e7e1fb]
./blender(DEG_ids_check_recalc+0x46) [0x1369206]
./blender() [0x126cccd]
./blender(wm_event_do_depsgraph+0xc3) [0x150e5b3]
./blender(wm_event_do_refresh_wm_and_depsgraph+0x87) [0x150e717]
./blender(wm_event_do_notifiers+0x472) [0x1513fe2]
./blender(WM_main+0x28) [0x150a658]
./blender(main+0x2fe) [0x10b59de]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f6403d9bb97]
./blender() [0x1144abc]

Sybren A. Stüvel (sybren) lowered the priority of this task from 90 to High.

I can confirm this. Here is a stack trace from a debug build:

==8229==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000006c (pc 0x55febb7aa292 bp 0x7ffea81a5080 sp 0x7ffea81a5070 T0)
==8229==The signal is caused by a READ memory access.
==8229==Hint: address points to the zero page.
    #0 0x55febb7aa291 in ccl::Shader::tag_used(ccl::Scene*) /home/sybren/workspace/blender-git/blender/intern/cycles/render/shader.cpp:358
    #1 0x55feb0243dbc in ccl::BlenderSync::find_shader(BL::ID&, ccl::vector<ccl::Shader*, ccl::GuardedAllocator<ccl::Shader*> >&, ccl::Shader*) /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_shader.cpp:49
    #2 0x55feb01d0c0b in ccl::BlenderSync::sync_light(BL::Object&, int*, BL::Object&, BL::Object&, int, ccl::Transform&, bool*) /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_object.cpp:200
    #3 0x55feb01d2b4a in ccl::BlenderSync::sync_object(BL::Depsgraph&, BL::ViewLayer&, BL::DepsgraphObjectInstance&, float, bool, bool, ccl::BlenderObjectCulling&, bool*) /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_object.cpp:321
    #4 0x55feb01d62b7 in ccl::BlenderSync::sync_objects(BL::Depsgraph&, float) /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_object.cpp:552
    #5 0x55feb0182e40 in ccl::BlenderSync::sync_data(BL::RenderSettings&, BL::Depsgraph&, BL::SpaceView3D&, BL::Object&, int, int, void**) /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_sync.cpp:213
    #6 0x55feb01618fa in ccl::BlenderSession::synchronize(BL::Depsgraph&) /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_session.cpp:881
    #7 0x55feb013c932 in sync_func /home/sybren/workspace/blender-git/blender/intern/cycles/blender/blender_python.cpp:399
    #8 0x7f365d011948 in _PyMethodDef_RawFastCallKeywords (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x244948)
    #9 0x7f365d0126b4 in _PyCFunction_FastCallKeywords (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x2456b4)
    #10 0x7f365ce43b0f in _PyEval_EvalFrameDefault (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x76b0f)
    #11 0x7f365ce45a42  (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x78a42)
    #12 0x7f365ce43649 in _PyEval_EvalFrameDefault (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x76649)
    #13 0x7f365ce45a42  (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x78a42)
    #14 0x7f365d0121e2 in _PyFunction_FastCallDict (/usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0+0x2451e2)
    #15 0x55feafac62de in bpy_class_call /home/sybren/workspace/blender-git/blender/source/blender/python/intern/bpy_rna.c:8295
    #16 0x55feafecf836 in engine_view_update /home/sybren/workspace/blender-git/blender/source/blender/makesrna/intern/rna_render.c:224
    #17 0x55febc051ed3 in ED_render_scene_update /home/sybren/workspace/blender-git/blender/source/blender/editors/render/render_update.c:138
    #18 0x55feaf92277d in DEG::deg_editors_scene_update(DEGEditorUpdateContext const*, bool) /home/sybren/workspace/blender-git/blender/source/blender/depsgraph/intern/depsgraph_update.cc:45
    #19 0x55feaf922031 in DEG_ids_check_recalc /home/sybren/workspace/blender-git/blender/source/blender/depsgraph/intern/depsgraph_tag.cc:768
    #20 0x55feaf4a3172 in scene_graph_update_tagged /home/sybren/workspace/blender-git/blender/source/blender/blenkernel/intern/scene.c:1575
    #21 0x55feaf4a31b2 in BKE_scene_graph_update_tagged /home/sybren/workspace/blender-git/blender/source/blender/blenkernel/intern/scene.c:1582
    #22 0x55feb008f73f in wm_event_do_depsgraph /home/sybren/workspace/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:369
    #23 0x55feb008f98d in wm_event_do_refresh_wm_and_depsgraph /home/sybren/workspace/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:395
    #24 0x55feb0090a2c in wm_event_do_notifiers /home/sybren/workspace/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:560
    #25 0x55feb0081d30 in WM_main /home/sybren/workspace/blender-git/blender/source/blender/windowmanager/intern/wm.c:420
    #26 0x55feaefa4ae6 in main /home/sybren/workspace/blender-git/blender/source/creator/creator.c:500
    #27 0x7f36557f1b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
    #28 0x55feaefa4179 in _start (/home/sybren/workspace/blender-git/build_debug/bin/blender+0x2da9179)

The call to shader_map.find(id) returns nullptr in BlenderSync::find_shader(...), which causes the subsequent crash.