Sculpt mode drawing leaks memory #76544

Closed
opened 2020-05-08 13:12:59 +02:00 by Campbell Barton · 15 comments
  • Run Blender with -d debug flag.
  • Open this file sculpt_mode_drawing_memory_leak.blend, exit Blender
  • Error: Not freed memory blocks: 26, total unfreed memory 0.002777 MB
  • Loading the file multiple times increase the number of leaks on exit.
- Run Blender with `-d` debug flag. - Open this file [sculpt_mode_drawing_memory_leak.blend](https://archive.blender.org/developer/F8520492/sculpt_mode_drawing_memory_leak.blend), exit Blender - `Error: Not freed memory blocks: 26, total unfreed memory 0.002777 MB` - Loading the file multiple times increase the number of leaks on exit.
Author
Owner

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Campbell Barton changed title from Sculpt mode leaks memory to Sculpt mode drawing leaks memory 2020-05-08 13:15:28 +02:00

Added subscriber: @Sergey

Added subscriber: @Sergey

Cant reproduce the leak, but do have some heap use after free: P1376
The leak might be different indication of the same root issue.

This is using blender 18f833be29 on Linux.

Cant reproduce the leak, but do have some heap use after free: [P1376](https://archive.blender.org/developer/P1376.txt) The leak might be different indication of the same root issue. This is using blender 18f833be29 on Linux.

Added subscriber: @ostapblender

Added subscriber: @ostapblender

I have similar behavior on Windows 10, but only when addons are enabled:
image.png

If addons folder are renamed to something different, no errors appear.

I have similar behavior on Windows 10, but only when addons are enabled: ![image.png](https://archive.blender.org/developer/F8520851/image.png) If addons folder are renamed to something different, no errors appear.
Member

Added subscriber: @ankitm

Added subscriber: @ankitm
Member

File shouldn't be required.. In sculpting workspace, enable Dyntopo, make a stroke, close file.

File shouldn't be required.. In sculpting workspace, enable Dyntopo, make a stroke, close file.

Added subscriber: @PabloDobarro

Added subscriber: @PabloDobarro

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Added subscriber: @JacquesLucke

Added subscriber: @JacquesLucke
Member

I tried to debug this for quite some time today, but I could not track down the root issue yet... I made some observations along the way though.
It's almost certainly a threading issue. I got many different outputs from asan. Furthermore, it's probably not only one issue, but multiple.

Reproduction steps:

  1. Open file.
  2. Start making brush strokes. Usually, it only takes one or two brush strokes to crash when ASAN is enabled.

#76544.blend

SCULPT_pbvh_calc_area_normal causes a warning: member call on address 0x613000adefc0 which does not point to an object of type 'task'. It does not seem to have a big impact, but it still feels like there is something wrong with the way parallel_reduce is used in BKE_pbvh_parallel_range.

Applying P1394 seems to fix all the issues for me. It disables threading in various locations. The patch also disables an unrelated assert, that should not be harmful. Enabling threading only on a single one of those, causes crashes. Depending on which one you enable, the crash looks is different. When more are enabled, it seems to be mostly a matter of luck which function fails first.

I tried to find some shared data that is not properly locked, but could not find any yet. I managed to get it working when I locked smaller code segments in the callbacks, but did not really win any significant insights from that.

I tried to debug this for quite some time today, but I could not track down the root issue yet... I made some observations along the way though. It's almost certainly a threading issue. I got many different outputs from asan. Furthermore, it's probably not only one issue, but multiple. Reproduction steps: 1. Open file. 2. Start making brush strokes. Usually, it only takes one or two brush strokes to crash when ASAN is enabled. [#76544.blend](https://archive.blender.org/developer/F8535433/T76544.blend) `SCULPT_pbvh_calc_area_normal` causes a warning: `member call on address 0x613000adefc0 which does not point to an object of type 'task'`. It does not seem to have a big impact, but it still feels like there is something wrong with the way `parallel_reduce` is used in `BKE_pbvh_parallel_range`. Applying [P1394](https://archive.blender.org/developer/P1394.txt) seems to fix all the issues for me. It disables threading in various locations. The patch also disables an unrelated assert, that should not be harmful. Enabling threading only on a single one of those, causes crashes. Depending on which one you enable, the crash looks is different. When more are enabled, it seems to be mostly a matter of luck which function fails first. I tried to find some shared data that is not properly locked, but could not find any yet. I managed to get it working when I locked smaller code segments in the callbacks, but did not really win any significant insights from that.

Added subscriber: @brecht

Added subscriber: @brecht

This sounds like multiple bugs in a single report? There's many different steps to redo and symptoms here.

The first issue is, does any of this happen in Blender in 2.83? If so, this should probably be a high priority bug. If not, it may be TBB related.

Further, git bisect might help pin down the cause?

This sounds like multiple bugs in a single report? There's many different steps to redo and symptoms here. The first issue is, does any of this happen in Blender in 2.83? If so, this should probably be a high priority bug. If not, it may be TBB related. Further, git bisect might help pin down the cause?

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Brecht Van Lommel self-assigned this 2020-05-18 17:47:09 +02:00

Regarding the various issues reported here:

  • Dyntopo memory leak reported by @ankitm: fixed with 20b94257dc.
  • Original memory leak in description: unable to reproduce. Assuming this has already been fixed. If it still happens, @ideasman42 should run Blender with --debug-memory and specify the revision tested.
  • GPU draw buffers user after free. Given the asan logs, assuming the issue found by @Sergey and @JacquesLucke is the same, and to be handled in #76858 (Threading issue in sculpt mode).
  • Memory leak reported by @ostapblender: this would be a bug in an add-on using the bgl module. If that's an add-on shipped with Blender, a bug can be reported for that add-on.
Regarding the various issues reported here: * Dyntopo memory leak reported by @ankitm: fixed with 20b94257dc. * Original memory leak in description: unable to reproduce. Assuming this has already been fixed. If it still happens, @ideasman42 should run Blender with `--debug-memory` and specify the revision tested. * GPU draw buffers user after free. Given the asan logs, assuming the issue found by @Sergey and @JacquesLucke is the same, and to be handled in #76858 (Threading issue in sculpt mode). * Memory leak reported by @ostapblender: this would be a bug in an add-on using the `bgl` module. If that's an add-on shipped with Blender, a bug can be reported for that add-on.
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
6 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#76544
No description provided.