Page MenuHome

Texture Paint behaving weird on Ctrl + Z sometimes
Closed, ResolvedPublic

Description

System Information
Operating system: Windows 10 64x
Graphics card: Geforce 1070

Blender Version

Broken: 690478027bd7

Short description of error

When pressing Ctrl + Z until undo all the brush strokes i did, the texture o the viewport was not going back to blank.
After a few trys, the file crashed. You can see it on the video. You will even see that after it crashed, it began to behave different.


Exact steps for others to reproduce the error
Based on the default startup or an attached .blend file (as simple as possible).

Details

Type
Bug

Event Timeline

I was able to show it better this time :

Sebastian Parborg (zeddb) triaged this task as Needs Information from User priority.

I think this might a be duplicate of T60660. Could you retest with the latest beta build?

Still not working with today's build (e63869ca802a)

I decided painting it on Substance Painter because the texture masks didn't seem to be working..

i tested it on a blank file, and there is something wrong here, it stopped working :

And now somehow it turned into this :

And pressing Ctrl + Z, the viewport normalized :

Sebastian Parborg (zeddb) raised the priority of this task from Needs Information from User to Confirmed, Medium.Jan 30 2019, 1:23 AM

I can reproduce this too, so the the undo bug seems to still be there.

@Campbell Barton (campbellbarton) It seems like the pink texture on undo is fixed now. However, if I paint some stroke and undo it segfaults sometimes with this test file.
In other cases, the texture is simply no longer updated in the viewport but you can see that you are drawing and updating the texture in the texture image view.
I have to undo again to make it display the updated texture in the 3D viewport.

Backtrace:

Thread 1 "blender" received signal SIGSEGV, Segmentation fault.
0x0000555557db7658 in bind_texture (tex=0x7fffeafaf248, bind_type=1 '\001')
    at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager_exec.c:926
926		slot_flags[bind_num] = bind_type;
(gdb) bt
#0  0x0000555557db7658 in bind_texture (tex=0x7fffeafaf248, bind_type=1 '\001')
    at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager_exec.c:926
#1  0x0000555557db7eec in draw_shgroup (shgroup=0x7fffcf571400, pass_state=32802)
    at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager_exec.c:1110
#2  0x0000555557db8a68 in drw_draw_pass_ex (pass=0x7fffceffc2e8, start_group=0x7fffcf571358, end_group=0x7fffcf571400)
    at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager_exec.c:1333
#3  0x0000555557db8be9 in DRW_draw_pass (pass=0x7fffceffc2e8)
    at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager_exec.c:1366
#4  0x0000555557dd8ad2 in PAINT_TEXTURE_draw_scene (vedata=0x7fffd11b0988)
    at /home/zed/programmering/blender_master/blender/source/blender/draw/modes/paint_texture_mode.c:342
#5  0x0000555557dab6fa in drw_engines_draw_scene () at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager.c:1089
#6  0x0000555557dac95a in DRW_draw_render_loop_ex (depsgraph=0x7fffd2bf7d08, engine_type=0x55555d269800 <DRW_engine_viewport_eevee_type>, ar=0x7fffd1abe9c8,
    v3d=0x7fffd2c14c08, viewport=0x7fffce6d4e88, evil_C=0x7ffff0030288)
    at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager.c:1543
#7  0x0000555557dac357 in DRW_draw_view (C=0x7ffff0030288) at /home/zed/programmering/blender_master/blender/source/blender/draw/intern/draw_manager.c:1421
#8  0x000055555722f6f7 in view3d_draw_view (C=0x7ffff0030288, ar=0x7fffd1abe9c8)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/space_view3d/view3d_draw.c:1340
#9  0x000055555722f7a7 in view3d_main_region_draw (C=0x7ffff0030288, ar=0x7fffd1abe9c8)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/space_view3d/view3d_draw.c:1361
#10 0x00005555576eedae in ED_region_do_draw (C=0x7ffff0030288, ar=0x7fffd1abe9c8)
    at /home/zed/programmering/blender_master/blender/source/blender/editors/screen/area.c:514
#11 0x00005555570e55ac in wm_draw_window_offscreen (C=0x7ffff0030288, win=0x7fffd1849188, stereo=false)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_draw.c:580
#12 0x00005555570e5b2a in wm_draw_window (C=0x7ffff0030288, win=0x7fffd1849188)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_draw.c:712
#13 0x00005555570e6036 in wm_draw_update (C=0x7ffff0030288)
    at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm_draw.c:866
#14 0x00005555570e2ccd in WM_main (C=0x7ffff0030288) at /home/zed/programmering/blender_master/blender/source/blender/windowmanager/intern/wm.c:431
#15 0x00005555570dd59e in main (argc=1, argv=0x7fffffffdd08) at /home/zed/programmering/blender_master/blender/source/creator/creator.c:520

@Sebastian Parborg (zeddb) interesting, I'm testing a bug which gives a backtrace in drawing too.
Automated steps are in this diff: https://developer.blender.org/D4286?id=13443#change-Dr6NjSaEnzSv

Can you try building w/ WITH_COMPILER_ASAN and see if its the same bug?

==19966==ERROR: AddressSanitizer: heap-use-after-free on address 0x6100001bc354 at pc 0x5621e4989e2f bp 0x7ffce0c361b0 sp 0x7ffce0c361a0
READ of size 4 at 0x6100001bc354 thread T0
    #0 0x5621e4989e2e in GPU_texture_bound_number /src/blender/source/blender/gpu/intern/gpu_texture.c:1356
    #1 0x5621e4ac8095 in bind_texture /src/blender/source/blender/draw/intern/draw_manager_exec.c:909
    #2 0x5621e4acbfa7 in draw_shgroup /src/blender/source/blender/draw/intern/draw_manager_exec.c:1110
    #3 0x5621e4acff71 in drw_draw_pass_ex /src/blender/source/blender/draw/intern/draw_manager_exec.c:1333
    #4 0x5621e4ad07bc in DRW_draw_pass /src/blender/source/blender/draw/intern/draw_manager_exec.c:1366
    #5 0x5621e4b6c444 in PAINT_TEXTURE_draw_scene /src/blender/source/blender/draw/modes/paint_texture_mode.c:342
    #6 0x5621e4a94625 in drw_engines_draw_scene /src/blender/source/blender/draw/intern/draw_manager.c:1089
    #7 0x5621e4a98990 in DRW_draw_render_loop_ex /src/blender/source/blender/draw/intern/draw_manager.c:1543
    #8 0x5621e4a97243 in DRW_draw_view /src/blender/source/blender/draw/intern/draw_manager.c:1421
    #9 0x5621e17bf5fc in view3d_draw_view /src/blender/source/blender/editors/space_view3d/view3d_draw.c:1340
    #10 0x5621e17bf7b7 in view3d_main_region_draw /src/blender/source/blender/editors/space_view3d/view3d_draw.c:1361
    #11 0x5621e2d8c95c in ED_region_do_draw /src/blender/source/blender/editors/screen/area.c:514
    #12 0x5621e11f35f1 in wm_draw_window_offscreen /src/blender/source/blender/windowmanager/intern/wm_draw.c:580
    #13 0x5621e11f4a71 in wm_draw_window /src/blender/source/blender/windowmanager/intern/wm_draw.c:712
    #14 0x5621e11f5cc0 in wm_draw_update /src/blender/source/blender/windowmanager/intern/wm_draw.c:866
    #15 0x5621e11e6207 in WM_main /src/blender/source/blender/windowmanager/intern/wm.c:431
    #16 0x5621e11d5e7c in main /src/blender/source/creator/creator.c:520
    #17 0x7f8196894222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)
    #18 0x5621e11d503d in _start (/src/cmake_debug/bin/blender+0xa0dc03d)

0x6100001bc354 is located 20 bytes inside of 184-byte region [0x6100001bc340,0x6100001bc3f8)
freed by thread T0 here:
    #0 0x7f8198381c19 in __interceptor_free /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:66
    #1 0x5621e6e5c1fd in MEM_lockfree_freeN /src/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:164
    #2 0x5621e498c289 in GPU_texture_free /src/blender/source/blender/gpu/intern/gpu_texture.c:1494
    #3 0x5621e492c0df in GPU_free_image /src/blender/source/blender/gpu/intern/gpu_draw.c:1149
    #4 0x5621e2efd774 in image_undo_restore_list /src/blender/source/blender/editors/sculpt_paint/paint_image_undo.c:330
    #5 0x5621e2eff073 in image_undosys_step_decode /src/blender/source/blender/editors/sculpt_paint/paint_image_undo.c:476
    #6 0x5621e5d67ffd in undosys_step_decode /src/blender/source/blender/blenkernel/intern/undo_system.c:201
    #7 0x5621e5d6e31e in BKE_undosys_step_undo_with_data_ex /src/blender/source/blender/blenkernel/intern/undo_system.c:665
    #8 0x5621e5d6ea36 in BKE_undosys_step_undo_with_data /src/blender/source/blender/blenkernel/intern/undo_system.c:688
    #9 0x5621e5d6eace in BKE_undosys_step_undo /src/blender/source/blender/blenkernel/intern/undo_system.c:693
    #10 0x5621e5d700da in BKE_undosys_step_undo_compat_only /src/blender/source/blender/blenkernel/intern/undo_system.c:783
    #11 0x5621e1323dd0 in ed_undo_step /src/blender/source/blender/editors/undo/ed_undo.c:176
    #12 0x5621e1325110 in ed_undo_exec /src/blender/source/blender/editors/undo/ed_undo.c:316
    #13 0x5621e12078e7 in wm_operator_invoke /src/blender/source/blender/windowmanager/intern/wm_event_system.c:1355
    #14 0x5621e120f16f in wm_handler_operator_call /src/blender/source/blender/windowmanager/intern/wm_event_system.c:2063
    #15 0x5621e1212d6e in wm_handlers_do_intern /src/blender/source/blender/windowmanager/intern/wm_event_system.c:2370
    #16 0x5621e1215ee2 in wm_handlers_do /src/blender/source/blender/windowmanager/intern/wm_event_system.c:2630
    #17 0x5621e121d757 in wm_event_do_handlers /src/blender/source/blender/windowmanager/intern/wm_event_system.c:3140
    #18 0x5621e11e61ef in WM_main /src/blender/source/blender/windowmanager/intern/wm.c:425
    #19 0x5621e11d5e7c in main /src/blender/source/creator/creator.c:520
    #20 0x7f8196894222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)

previously allocated by thread T0 here:
    #0 0x7f8198382231 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:95
    #1 0x5621e6e5c9a4 in MEM_lockfree_callocN /src/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:282
    #2 0x5621e49838f7 in GPU_texture_from_bindcode /src/blender/source/blender/gpu/intern/gpu_texture.c:909
    #3 0x5621e4925442 in GPU_texture_from_blender /src/blender/source/blender/gpu/intern/gpu_draw.c:361
    #4 0x5621e4b69968 in PAINT_TEXTURE_cache_init /src/blender/source/blender/draw/modes/paint_texture_mode.c:202
    #5 0x5621e4a936f7 in drw_engines_cache_init /src/blender/source/blender/draw/intern/draw_manager.c:991
    #6 0x5621e4a97b7c in DRW_draw_render_loop_ex /src/blender/source/blender/draw/intern/draw_manager.c:1477
    #7 0x5621e4a97243 in DRW_draw_view /src/blender/source/blender/draw/intern/draw_manager.c:1421
    #8 0x5621e17bf5fc in view3d_draw_view /src/blender/source/blender/editors/space_view3d/view3d_draw.c:1340
    #9 0x5621e17bf7b7 in view3d_main_region_draw /src/blender/source/blender/editors/space_view3d/view3d_draw.c:1361
    #10 0x5621e2d8c95c in ED_region_do_draw /src/blender/source/blender/editors/screen/area.c:514
    #11 0x5621e11f35f1 in wm_draw_window_offscreen /src/blender/source/blender/windowmanager/intern/wm_draw.c:580
    #12 0x5621e11f4a71 in wm_draw_window /src/blender/source/blender/windowmanager/intern/wm_draw.c:712
    #13 0x5621e11f5cc0 in wm_draw_update /src/blender/source/blender/windowmanager/intern/wm_draw.c:866
    #14 0x5621e11e6207 in WM_main /src/blender/source/blender/windowmanager/intern/wm.c:431
    #15 0x5621e11d5e7c in main /src/blender/source/creator/creator.c:520
    #16 0x7f8196894222 in __libc_start_main (/usr/lib/libc.so.6+0x24222)

SUMMARY: AddressSanitizer: heap-use-after-free /src/blender/source/blender/gpu/intern/gpu_texture.c:1356 in GPU_texture_bound_number
Sebastian Parborg (zeddb) closed this task as Resolved.EditedJan 31 2019, 6:46 PM
Sebastian Parborg (zeddb) claimed this task.

@Campbell Barton (campbellbarton) I can't seem to reproduce the segfault or the texture paint image not updating in viewport anymore with the latest commits.

Did you want me to test out the code that you linked to or was it only to help with debugging this (now seemingly solved) issue?

@Henrique Balduino Gonzaga (henriquebg88) Let me know if this is still a problem with a build from tomorrow.

Note, another undo/redo bug that seems related to this has been fixed rB87aa456ea516f49c6029cf30f8f0dff16cbb58bc.