Crash in subsurf_ccg.c ccgdm_getVertCos (possibly due to improper use of GET_INT_FROM_POINTER) #42748
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#42748
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I've been seeing this crash bug on my machine for a few months, repro steps are unstable and usually involve me picking up one bone on my an armature attached to my mesh then wildly moving the mouse for minutes. Given the un-usable repro steps, I decided to pull down tip blender source (as of yesterday) to get a full callstack. Hopefully the detailed callstack will prove more helpful than the repro steps.
As mentioned in the title, all the crashes I've seen occur in ccgdm_getVertCos, either in the last loop or second-to-last loop in the file. The crashes all seem to be related to vertMap2 containing invalid data; I thought I could get away with adding nullguards for the return value of ccgSubSurf_getEdgeData and the contents of vertMap2[index], but most recently I've gotten a crash due to vertMap2 containing a non-null invalid pointer. Here is some more details for the application state on that referenced crash (which occurred in the final loop in the referenced function):
totvert = 146
index = 2
vertMap2[index] = 0x0000000500000004 {next=??? vHDL=??? numEdges=??? ...}
and the first few entries in vertMap2:
I can't really make heads or tails of this code but in general casting an arbitrary pointer to an int seems like a very bad idea, which the comments next to the GET_INT_FROM_POINTER macro seem to agree with
Changed status to: 'Open'
Added subscriber: @pyro789x
I did not attach the callstack because I am dumb. Here it is:
Added subscriber: @mont29
Thanks for the report and investigation, but unfortunately I doubt we can do much with those data so far. The fact that it happens randomly (and after some long time, several minutes of moving mouse is very from a program pov).
Such random issue can be caused either by a threading issue, or some hardware problem, usually. Checking threading is easy: please start Blender with
-t 1
commandline option, and see whether you can reproduce the bug.Otherwise, we’ll need a .blend file with as precise as possible repro instructions.
Note that get/set int in pointer is widely used across our whole code base, it’s very unlikely to be the issue here.
Your hunch appears to be correct, I cannot reproduce the crash when I start blender with the '-t 1' command line argument.
I would like to upload my .blend file, but the file size of 7,924KB compressed (42,664KB uncompressed) seems to be larger than the limit set by this site. What is the standard location for uploading .blend files?
Regarding the current file size, I think I've removed as much as I could from the .blend file without negatively affecting the repro rate. Removing certain textures, meshes or bones increases the amount of time required to reproduce the issue. WIth the 42MB file I can reproduce the issue by grabbing ('G') the 'torso' bone and moving the mouse around for 3 to 15 seconds.
eeeeh, sorry for not answering sooner, you can just use another host for the file, like google doc, dropbox, and such.
Here it is: https://www.dropbox.com/s/27awfdcuy65m4s0/crash-2s.7z?dl=0
Thanks for the response
Thanks for the file, can easily confirm the crash here (thread using some mem already freed by another thread...).
Added subscriber: @Sergey
So... As far as I can say, meshdeform modifier ends up using a derivedFinal DM from its target that gets freed in the mean time. At least, that what I guess from sanitize messages below:
P173: #42748
Note I also got one much more interesting once (saying 'thread A using mem freed by thread B', but unfortunately I could never reproduce it.
Also, the bug itself is very evanescent, sometimes you can get it five times in a row, and then you have to try ten times or more before you can reproduce it again. :/
Sergey, I really need your help here, I would think that kind of thing is not supposed to happen ever?
@mont29, i'm not sure how to reproduce the crash. I don't even see asan reports here.
Could see three possibilities:
You should be able to run blender in gdb and once it'll crash type
thread apply all bt
. That would give some extra info.OK, thanks for the tips. So, following gdb session (very hard to get it crashing in debugger :( ) indeed seems to imply
ccgdm_getVertCos
is not threadsafe. More precisely, It seems CCG iterators are not.P174: #42748
And after 'protecting' the iterator crap behind a mutex lock (see patch below), I'm unable to reproduce the crash anymore.
P175: #42748
Now, I do not understand from a first look why CCG iterators would not be thread safe, they seem to use their own counters and everything, and only read common 'shared' data from SS struct?
Because if we have to explicitly thread-protect all uses of those iterators...
I'd say it's allocation is not thread safe. Couple of ideas:
Added subscriber: @ideasman42
Ok, so here is a patch to make memarena threadsafe.
Notes:
P176: #42748
Campbell, your advice would be most welcomed here as well! :)
Argh, there's a reason we've got differencial nowadays! :P Would be easier to give feedback on the patch :) Do you mind re-uploading it to the code review?
sure sec :)
Using arena for iterators here is really bad, since these iterators are used while drawing (looks like its probably leaking memory even).
Using stack memory for iterators fixes. will commit shortly
Edit, I couldn't get it to leak memory, so in practice it seems ok (but still error prone for leaks).
This issue was referenced by
602250d9fe
Changed status from 'Open' to: 'Resolved'
Closed by commit
602250d9fe
.For the records, here is a light file that should crash pretty much instantaneously on any machine (using build previous to above commit).
crash-2s_b.blend