2.78 crash on image datablock removal #49590

Closed
opened 2016-10-06 14:01:34 +02:00 by notallowed · 15 comments

System Information
Linux Mint 17.3, Nvidia GeForce GTX 760

Blender Version
Broken: 2.78.4bb1e22
Worked: 2.77a

Short description of error
Blender crashes when removing image datablock with Python API in attached blend file.
For easy testing attached blend file already has text "images_removal" which should remove all images, but crashes blender instead.

I also tried to use -d option and --factory-settings but still crashing. Moreover I even tried todays buildbot build: 2.78.3caa830 but still crashing.

However I did try to test this on different PC with Windows platform and released 2.78 version where crash did not appear.

Exact steps for others to reproduce the error

  1. Open attached "truck.blend" file and load UI from it.
  2. Navigate to Text Editor and run embedded "images_removal" script.
  3. Crash.

truck.blend
truck.crash.txt

**System Information** Linux Mint 17.3, Nvidia GeForce GTX 760 **Blender Version** Broken: 2.78.4bb1e22 Worked: 2.77a **Short description of error** Blender crashes when removing image datablock with Python API in attached blend file. For easy testing attached blend file already has text "images_removal" which should remove all images, but crashes blender instead. I also tried to use -d option and --factory-settings but still crashing. Moreover I even tried todays buildbot build: 2.78.3caa830 but still crashing. However I did try to test this on different PC with Windows platform and released 2.78 version where crash did not appear. **Exact steps for others to reproduce the error** 1. Open attached "truck.blend" file and load UI from it. 2. Navigate to Text Editor and run embedded "images_removal" script. 3. Crash. [truck.blend](https://archive.blender.org/developer/F374617/truck.blend) [truck.crash.txt](https://archive.blender.org/developer/F374618/truck.crash.txt)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @simon_lusenc

Added subscriber: @simon_lusenc

Added subscribers: @mont29, @Sergey

Added subscribers: @mont29, @Sergey
Bastien Montagne was assigned by Sergey Sharybin 2016-10-06 14:21:03 +02:00

@mont29, my guess would be the ID remap is involved here. Mind having a look? :)

@mont29, my guess would be the ID remap is involved here. Mind having a look? :)

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

I kinda seriously doubt this ever worked, except by mistake/luck… You are blindly setting usercount of images to zero (user_clear()), and then delete them, whithout any care about potential actual users of those images.

You should not have to touch to image usercount anymore at all, just call bpy.data.images.remove(bpy.data.images- [x], do_unlink=True) is enough, do_unlink tells Blender to handle correctly all users of removed datablock.

No bug here, this clear_user() is actually a very bad (and dangerous, nice crash generator!) hack that used to be needed to work around our very weak handling of usercount in previous code, starting from 2.78 you should not need it anymore. Will add a note to releaselogs about it.

I kinda seriously doubt this ever worked, except by mistake/luck… You are blindly setting usercount of images to zero (`user_clear()`), and then delete them, whithout any care about potential actual users of those images. You should not have to touch to image usercount anymore at all, just call `bpy.data.images.remove(bpy.data.images- [x], do_unlink=True)` is enough, `do_unlink` tells Blender to handle correctly all users of removed datablock. No bug here, this `clear_user()` is actually a very bad (and dangerous, nice crash generator!) hack that used to be needed to work around our very weak handling of usercount in previous code, starting from 2.78 you should not need it anymore. Will add a note to releaselogs about it.
Author

@mont29 Well using new way of removal aka bpy.data.images.remove(bpy.data.images- [x], do_unlink=True) without "clear_user" doesn't help, blender still crashes. That's why I reported this, because no matter what I do I seem to not get around it on Linux.

EDIT: Now I even tried to remove all users via Shift + Click in UV Editor and then run the script only with "....remove(img, do_unlink=True)", still crashing. However in this case I got output to console:
ID user decrement error: IM4x2_bp.png (from '[Main]'): 0 <= 0
ID user count error: IM4x2_bp.png (from '[Main]')
ID user count error: IM4x2_bp.png (from '[Main]')

@mont29 Well using new way of removal aka bpy.data.images.remove(bpy.data.images- [x], do_unlink=True) without "clear_user" doesn't help, blender still crashes. That's why I reported this, because no matter what I do I seem to not get around it on Linux. EDIT: Now I even tried to remove all users via Shift + Click in UV Editor and then run the script only with "....remove(img, do_unlink=True)", still crashing. However in this case I got output to console: ID user decrement error: IM4x2_bp.png (from '[Main]'): 0 <= 0 ID user count error: IM4x2_bp.png (from '[Main]') ID user count error: IM4x2_bp.png (from '[Main]')

Changed status from 'Archived' to: 'Open'

Changed status from 'Archived' to: 'Open'

Eeeeh… OK, can confirm… please try to always report minimal case of bugs, the more you add to it, the more confusing it can be (and using clear_user to fix a crash is certainly not the way to go ;) )

Eeeeh… OK, can confirm… please try to always report minimal case of bugs, the more you add to it, the more confusing it can be (and using clear_user to fix a crash is certainly not the way to go ;) )

That .blend file is corrupted… 3DView's background pictures list is broken (last item does not have correct breaking NULL next pointer)…

Looks like I cannot reproduce this state from startup file, so afraid we need a way to reproduce this broken .blend file here.

That .blend file is corrupted… 3DView's background pictures list is broken (last item does not have correct breaking NULL next pointer)… Looks like I cannot reproduce this state from startup file, so afraid we need a way to reproduce this broken .blend file here.
Author

Well history of that file is quite long, I think that from blender version 2.74.
However I was able to recover SVN version of file that was still okay (executing above script didn't crash in 2.78), so hopefully it's not corrupted yet.

Now would it help if I would give you corrupted and non-corrupted files?

PS:
I am using unofficial addon on it, which uses pre_save handlers executing this:

    # clear unused materials, this has to be done because of usage of same material inside nodes
    for material in bpy.data.materials:
        if material.node_tree and material.users == 1:
            for node in material.node_tree.nodes:
                if node.type in ("MATERIAL_EXT", "MATERIAL"):
                    if node.material == material:
                        material.user_clear()

Might this be a source of problem, as user_clear is used again?

Well history of that file is quite long, I think that from blender version 2.74. However I was able to recover SVN version of file that was still okay (executing above script didn't crash in 2.78), so hopefully it's not corrupted yet. Now would it help if I would give you corrupted and non-corrupted files? PS: I am using unofficial addon on it, which uses pre_save handlers executing this: ``` # clear unused materials, this has to be done because of usage of same material inside nodes for material in bpy.data.materials: if material.node_tree and material.users == 1: for node in material.node_tree.nodes: if node.type in ("MATERIAL_EXT", "MATERIAL"): if node.material == material: material.user_clear() ``` Might this be a source of problem, as user_clear is used again?

Well… what I need here is a way (steps) to reproduce corrupted file from sane one…

Don’t think that code can cause the issue, corruption is with the background pics list of the 3DView, so most likely some operation done at some point with those background images broke it (or, some versionning code between two releases of Blender went wrong, or, if you also opened and saved the file with some non-release builds, a transitional bug broke it, or…).

Typical case actually, a broken file is nearly never enough to understand the problem, without a way to reproduce it there are just too much possible causes to investigate them. :)

Well… what I need here is a way (steps) to reproduce corrupted file from sane one… Don’t think that code can cause the issue, corruption is with the background pics list of the 3DView, so most likely some operation done at some point with those background images broke it (or, some versionning code between two releases of Blender went wrong, or, if you also opened and saved the file with some non-release builds, a transitional bug broke it, or…). Typical case actually, a broken file is nearly never enough to understand the problem, without a way to reproduce it there are just too much possible causes to investigate them. :)
Author

Hm... it doesn't look good then, because I don't have exact steps :/

What I can tell is that between recovered SVN versions I was working with UV editor and changing vertex UVs. Also I was opening some images just for the period of changing UV layers. After I was done, I removed that images trough editor Shift + Click and re-saving the file. But I am sure that I wasn't working with background images at that time.

PS: Out of curiosity I tried to open latest corrupted blend file without loading UI and running that script does not crash blender anymore. So once opening that blend file without UI and saving file again should remove corruption problems? Is there any way I can check integrity of blend file?

Hm... it doesn't look good then, because I don't have exact steps :/ What I can tell is that between recovered SVN versions I was working with UV editor and changing vertex UVs. Also I was opening some images just for the period of changing UV layers. After I was done, I removed that images trough editor Shift + Click and re-saving the file. But I am sure that I wasn't working with background images at that time. PS: Out of curiosity I tried to open latest corrupted blend file without loading UI and running that script does not crash blender anymore. So once opening that blend file without UI and saving file again should remove corruption problems? Is there any way I can check integrity of blend file?

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

Ah yes indeed, since broken stuff is in UI area, loading without UI shall fix the issue completely. :)

And no, no universal way to check a .blend file, aside from checking whether it crashes or not Blender xD

Will archive the report for now, we can always re-open it should you be able to reproduce the issue some day.

Ah yes indeed, since broken stuff is in UI area, loading without UI shall fix the issue completely. :) And no, no universal way to check a .blend file, aside from checking whether it crashes or not Blender xD Will archive the report for now, we can always re-open it should you be able to reproduce the issue some day.
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
3 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#49590
No description provided.