bmesh.types.Bmesh.faces.sort() crashes blender on windows only #51072

Closed
opened 2017-03-28 20:17:25 +02:00 by Geoffrey Bantle · 10 comments

System Information
Windows 7 Enterprise 64 bit

Blender Version
Works Blender 2.75a 64 bit official windows build
Broken Blender 2.78c 64 bit official windows build

Short description of error
According to blender python documentation you can assign the index of each face in a bmesh a value and then later use those values to sort the faces.

See

https:*docs.blender.org/api/2.78b/bmesh.types.html#bmesh.types.BMFace.index And https:*docs.blender.org/api/2.78b/bmesh.types.html#bmesh.types.BMFaceSeq.sort

In the file this_file_crashes.blend is a script, run_me. It assigns each face in a subdivided cube a unique, non-negative index. After calling bmesh.types.Bmesh.faces.sort() blender crashes with the message:

Error: EXCEPTION_ACCESS_VIOLATION

This error has been reproduced on 4 separate windows systems. Several linux machines have been tested but the error does not occur there.

Steps to reproduce

  • Open Blender v2.78c 64 bit on windows.
  • Open the file this_file_crashes.blend
  • Run the script run_me
  • Blender should crash

Also

  • Open Blender v2.75a 64 bit on windows
  • Open the file this_file_crashes.blend
  • Run the script run_me
  • Blender should not crash

Finally

  • Open Blender v2.78c 64 bit on windows.
  • Open the file this_file_does_not_crash.blend
  • Run the script run_me
  • Blender should not crash

this_file_crashes.blend

this_file_does_not_crash.blend
The only difference between the scripts in the two blend files is the call to bmesh.types.Bmesh.faces.sort()

**System Information** Windows 7 Enterprise 64 bit **Blender Version** *Works* Blender 2.75a 64 bit official windows build *Broken* Blender 2.78c 64 bit official windows build **Short description of error** According to blender python documentation you can assign the index of each face in a bmesh a value and then later use those values to sort the faces. *See* [[ https:*docs.blender.org/api/2.78b/bmesh.types.html#bmesh.types.BMFace.index ]]*And*[[ https:*docs.blender.org/api/2.78b/bmesh.types.html#bmesh.types.BMFaceSeq.sort ]] In the file *this_file_crashes.blend* is a script, *run_me*. It assigns each face in a subdivided cube a unique, non-negative index. After calling bmesh.types.Bmesh.faces.sort() blender crashes with the message: > Error: EXCEPTION_ACCESS_VIOLATION This error has been reproduced on 4 separate windows systems. Several linux machines have been tested but the error does not occur there. **Steps to reproduce** - Open Blender v2.78c 64 bit on windows. - Open the file *this_file_crashes.blend* - Run the script *run_me* - Blender should crash *Also* - Open Blender v2.75a 64 bit on windows - Open the file *this_file_crashes.blend* - Run the script *run_me* - Blender should not crash *Finally* - Open Blender v2.78c 64 bit on windows. - Open the file *this_file_does_not_crash.blend* - Run the script *run_me* - Blender should not crash [this_file_crashes.blend](https://archive.blender.org/developer/F526691/this_file_crashes.blend) [this_file_does_not_crash.blend](https://archive.blender.org/developer/F526692/this_file_does_not_crash.blend) The only difference between the scripts in the two blend files is the call to bmesh.types.Bmesh.faces.sort()

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @gbantle-3

Added subscriber: @gbantle-3

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Interesting that when putting del(face) before bm.faces.sort(), the crash does not occur.
This implies that bm.free() does not invalidate the previously referenced faces. And the dealloc tries to read a self->bm that no longer exists.

Interesting that when putting `del(face)` before `bm.faces.sort()`, the crash does not occur. This implies that bm.free() does not invalidate the previously referenced faces. And the dealloc tries to read a self->bm that no longer exists.

That makes sense. Could this be the source of the problem?

bm_mesh_remap_cd_update(&(*fap)->head, &new_fap->head, cd_poly_pyptr);

in bmesh_mesh.c at line 1636.

It looks to me like that might be where the python face is copied over to a new one after the sort and left dangling.

That makes sense. Could this be the source of the problem? > bm_mesh_remap_cd_update(&(*fap)->head, &new_fap->head, cd_poly_pyptr); in *bmesh_mesh.c* at line *1636*. It looks to me like that might be where the python face is copied over to a new one after the sort and left dangling.

In #51072#425197, @gbantle-3 wrote:
That makes sense. Could this be the source of the problem?

bm_mesh_remap_cd_update(&(*fap)->head, &new_fap->head, cd_poly_pyptr);

in bmesh_mesh.c at line 1636.

It looks to me like that might be where the python face is copied over to a new one after the sort and left dangling.

Yes you are right. And it seems to be related to 9304df5182

The reference of a pyobject may be being overwritten in bm_mesh_remap_cd_update and set to NULL :\

> In #51072#425197, @gbantle-3 wrote: > That makes sense. Could this be the source of the problem? > >> bm_mesh_remap_cd_update(&(*fap)->head, &new_fap->head, cd_poly_pyptr); > > in *bmesh_mesh.c* at line *1636*. > > It looks to me like that might be where the python face is copied over to a new one after the sort and left dangling. Yes you are right. And it seems to be related to 9304df5182 The reference of a pyobject may be being overwritten in `bm_mesh_remap_cd_update` and set to NULL :\
Campbell Barton was assigned by Germano Cavalcante 2017-03-29 08:09:22 +02:00

@ideasman42 Here is a possible solution -> D2587

@ideasman42 Here is a possible solution -> [D2587](https://archive.blender.org/developer/D2587)

Added subscriber: @SteffenD

Added subscriber: @SteffenD

This issue was referenced by d097c2a1b3

This issue was referenced by d097c2a1b3155bf287abf72d56e1ab3a57b8b870

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
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
4 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#51072
No description provided.