Maniphest T47971

Blender 2.77 Crash When Rigid Body Cache 'Bake' Clicked
Closed, Resolved

Assigned To
None
Authored By
Bob Wise (BCTracker)
Mar 27 2016, 11:20 PM
Tags
  • BF Blender
  • BF Blender: Regressions
Subscribers
Bob Wise (BCTracker)
Brecht Van Lommel (brecht)
Lukas Tönne (lukastoenne)

Description

System Information
Operating system and graphics card
Dell Studio 1749 (64 bit)
Intel Core i5 CPU M 520 @ 2GHz 2 Cores, 4 Logical Processors
8.0 GB memory installed

MIcrosoft WIndows 10 Pro, ver 10.0.10586 Build 10586
ATI Mobility Radeon HD 5650
4 MB Graphics Memory

Blender Version
Broken: 2.77 - 22a2853
Worked: 2.76b f337fea

Short description of error
Have ~ 14,000 Rigid Body objects. When press Rigid Body Cache 'Bake' - Blender immediately crashes. No time to see error message if any.

**Exact steps for others to reproduce the error*
Create ~14,000 Rigid Body Ico Spheres (Active, Dynamic, Convex Hull, Base)
Save
Create animated mesh 'foot' (No armature or bones) (Dynamic, animated, Convex Hull Deform)
Save
Create 3D rectangular collision surface where Ico Spheres will land. (Passive, Convex Hull)
Save
During animation 'foot' walks across Ico Spheres leaving a track.

Press 'Rigid Body Cache' 'Bake'
Based on a (as simple as possible) attached .blend file with minimum amount of steps

Thanks! ... Blender is awesome!

Revisions and Commits

rB Blender
Audited

Related Objects

Mentioned In
T48037: 2.77 and 2.69 both on Windows and Linux crashes when trying to play (unbaked,first try,play) rigid body physics
rBbd0223b8fefe: Fix T47351: slow rigid body sim bake after recent changes to use jobs system.
Mentioned Here
rBbd0223b8fefe: Fix T47351: slow rigid body sim bake after recent changes to use jobs system.
rBf337feaf5a1d: BLender 2.76: We go 'b' series now
rB22a2853b5d56: Blender 2.77: Point submodules to an updated hashes

Event Timeline

Bob Wise (BCTracker) created this task.Mar 27 2016, 11:20 PM
Bob Wise (BCTracker) raised the priority of this task from to 90.
Bob Wise (BCTracker) updated the task description.
Bob Wise (BCTracker) added a project: BF Blender.
Bob Wise (BCTracker) edited a custom field.
Bob Wise (BCTracker) added a subscriber: Bob Wise (BCTracker).
perfection cat (sindra1961) added a subscriber: perfection cat (sindra1961).Mar 28 2016, 6:44 AM

I suggest that you attach a more lightweight sample file.

perfection cat (sindra1961) removed a subscriber: perfection cat (sindra1961).Mar 28 2016, 6:44 AM
Lukas Tönne (lukastoenne) lowered the priority of this task from 90 to 50.Mar 28 2016, 3:20 PM
Lukas Tönne (lukastoenne) added a subscriber: Lukas Tönne (lukastoenne).

Yes, this test file is unnecessarily big, the error still occurs with just one of the rigid bodies as well. That's why it says "as simple as possible" in the instructions!

That being said, the error seems to be a threading bug of the point cache. The Bake operator starts a job, which runs in the background until completed or cancelled. The operator meanwhile returns immediately. Now, when the operator returns, it triggers an undo push, which writes a .blend file containing the memory (non-disk) point cache data. Due to the pointcache implementation writing to the same data during bake, the file writing uses an undefined memory state, and can crash when attempting to access information about internal data arrays of the cache, which are still being set up in another thread at that point.
https://developer.blender.org/diffusion/B/browse/master/source/blender/blenloader/intern/writefile.c$1130

The point cache is considered broken in any case. Among lots of other issues, a job should not work on DNA data directly like this, but use separate data which only gets sync'd with DNA on completion. As a short term solution we could disable threading for point cache bake ...

Bob Wise (BCTracker) added a comment.Mar 28 2016, 4:01 PM

Thanks both of you!

I can use Blender 2.76b for now, so no urgency, or need for special fix on my part.

Sorry file was unnecessarily bulky... would have simplified file more, but unsure what was causing problem so not certain what was safe to delete.

Would like to know when problem is fixed though so I can use new Blender version for this work.

I really appreciate Blender and all the work that's gone into it. Nothing like being able to demonstrate exactly what you see in your mind...something words just don't do!

Lukas Tönne (lukastoenne) added a commit: rBbd0223b8fefe: Fix T47351: slow rigid body sim bake after recent changes to use jobs system..Mar 28 2016, 4:16 PM
Lukas Tönne (lukastoenne) mentioned this in rBbd0223b8fefe: Fix T47351: slow rigid body sim bake after recent changes to use jobs system..
Lukas Tönne (lukastoenne) added a comment.Mar 28 2016, 4:20 PM

See comment here rBbd0223b8fefe1bf21f9cd2b444256775b5540227, this change probably awakened the dormant race condition in point cache ...

Campbell Barton (campbellbarton) added a project: BF Blender: Regressions.Mar 28 2016, 5:03 PM
Brecht Van Lommel (brecht) changed the task status from Unknown Status to Resolved by committing rB74e40663da69: Fix T47971: rigid body baking crash due to thread race condition..Apr 2 2016, 1:27 PM
Brecht Van Lommel (brecht) added a commit: rB74e40663da69: Fix T47971: rigid body baking crash due to thread race condition..
Brecht Van Lommel (brecht) added a subscriber: Brecht Van Lommel (brecht).Apr 2 2016, 1:28 PM

The UI is locked during bake, so generally it should be thread safe, just this undo push slipped through.

I've now changed the bake operator to work like the render operator, it keeps running as a modal operator until the job is finished. That's also generally more correct, as we want all changes made by the bake job to be included in the undo push.