Texture paint after render whilst in texture paint mode causes crash - something in undo code seems to be the cause #54546

Closed
opened 2018-04-08 19:55:10 +02:00 by Rob Hughes · 5 comments

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.

paintCrash.blend

**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. [paintCrash.blend](https://archive.blender.org/developer/F2633381/paintCrash.blend)
Author

Added subscriber: @RevDr

Added subscriber: @RevDr
Member

Added subscribers: @ideasman42, @lichtwerk

Added subscribers: @ideasman42, @lichtwerk
Campbell Barton was assigned by Philipp Oeser 2018-04-09 10:14:22 +02:00
Member

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

@ideasman42: 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 

I can confirm the crash in undo (in current master -- while 2.79b doesnt have the issue) @ideasman42: 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 ```
Author

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- [x] == '\0') is actually needed - does that stop changing of us->name if it is already set.

Anyway - hope that helps a little.

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- [x] == '\0') is actually needed - does that stop changing of us->name if it is already set. Anyway - hope that helps a little.
Member

Closed as duplicate of #54584

Closed as duplicate of #54584
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#54546
No description provided.