Page MenuHome

Texture paint after render whilst in texture paint mode causes crash - something in undo code seems to be the cause
Closed, DuplicatePublic

Description

System Information
Windows 10 - 5820K - GTX 970

Blender Version
Latest local build from master (8th April)

Short description of error
Attempting texture painting after a render (whilst in texture painting mode in viewport) causes an immediate crash.

Debugger drops me into the undo code.

Exact steps for others to reproduce the error

  1. Load attached scene
  2. Render (F12)
  3. Paint a stroke on the icosphere
  4. Crash follows immediately on my machine

'Interestingly' if you

  1. come out of texture paint mode
  2. render
  3. go back into texture paint mode
  4. paint a stroke

All is ok.

So it seems issue is caused by rendering whilst in texture paint mode.

Details

Type
Bug

Event Timeline

Philipp Oeser (lichtwerk) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

I can confirm the crash in undo (in current master -- while 2.79b doesnt have the issue)

@Campbell Barton (campbellbarton): this one is for you? (feel free to throw back at me for further investigation, but seems due to recent undo refactor?)

1  BLI_strnlen                     string.c           757  0x29fd856 
2  BLI_strncpy                     string.c           116  0x29fc586 
3  BKE_undosys_step_push_with_type undo_system.c      423  0x2724c09 
4  BKE_undosys_step_push           undo_system.c      448  0x2724d48 
5  ED_image_undo_push_end          paint_image_undo.c 358  0x1dc6459 
6  paint_stroke_done               paint_image.c      576  0x1da8314 
7  stroke_done                     paint_stroke.c     754  0x1dcf446 
8  paint_stroke_modal              paint_stroke.c     1176 0x1dd076f 
9  wm_handler_operator_call        wm_event_system.c  1743 0x1801f91 
10 wm_handlers_do_intern           wm_event_system.c  2156 0x1802ffb 
11 wm_handlers_do                  wm_event_system.c  2195 0x18030f4 
12 wm_event_do_handlers            wm_event_system.c  2481 0x1803d94 
13 WM_main                         wm.c               522  0x17f744c 
14 main                            creator.c          539  0x17f1ebd
Rob Hughes (RevDr) added a comment.EditedApr 10 2018, 12:11 PM

OK - have spent a little time looking at the code.

I know why the crash is happening and have a (probably incorrect!) solution.

Firstly the reason...
In undo_system.c: the function BKE_undosys_step_push_with_type is called with a NULL value for string.
The string is set higher up in the stack in paint_image_undo.c function ED_image_undo_push_end which makes the call BKE_undosys_step_push(ustack, NULL, NULL).

When BKE_undosys_step_push_with_type tries to do a BLI_strncpy (line 423) it crashes because the string it is copying is NULL.

In my local copy I changed line 422

if (us->name[0] == '\0') {

to be

if ((us->name[0] == '\0') && (name!=NULL)){

which seems to fix the crash.

However, I am not sure if
a. name should ever have been passed as NULL and what the implications of ignoring that are
b. if (us->name[0] == '\0') is actually needed - does that stop changing of us->name if it is already set.

Anyway - hope that helps a little.