Image editor assert when image is unlinked [with setting users to zero] #75675

Closed
opened 2020-04-13 11:50:23 +02:00 by Antonio Vazquez · 21 comments

Blender 2.83 compiled with last source code at 13/04/2020 11:48
Windows 10 64 bits - RTX2080TI

After unlink [with setting users to zero -- {key Shift click}] several times the same image appears an assert. I could replicate several times the same crash

2020-04-13 11-47-29.mp4

Here the call stack of the crash.

20: BLI_system_backtrace - 0x7FF73E6933D0
19: id_us_ensure_real - 0x7FF7377301D0
18: ED_space_image_set - 0x7FF738CECAD0
17: rna_SpaceImageEditor_image_set - 0x7FF7381CDFB0
16: SpaceImageEditor_image_set - 0x7FF73819F670
15: RNA_property_pointer_set - 0x7FF737FEA6D0
14: template_ID_set_property_cb - 0x7FF738BA3670
13: ui_apply_but_funcs_after - 0x7FF738B6D0B0
12: ui_handler_region_menu - 0x7FF738B84030
11: wm_handler_ui_call - 0x7FF737B5E3C0
10: wm_handlers_do_intern - 0x7FF737B5FF20
9: wm_handlers_do - 0x7FF737B5E9E0
8: wm_event_do_handlers - 0x7FF737B59590
7: WM_main - 0x7FF737B2FD50
6: main - 0x7FF7373A7930
5: invoke_main - 0x7FF73E930510
4: __scrt_common_main_seh - 0x7FF73E9302C0
3: __scrt_common_main - 0x7FF73E9302A0
2: mainCRTStartup - 0x7FF73E9305D0
1: BaseThreadInitThunk - 0x7FF9DA4C7BC0
0: RtlUserThreadStart - 0x7FF9DBCECEB0
BLI_assert failed: D:\MyBlender\BlenderDEV\blender\source\blender\blenkernel\intern\lib_id.c:263, id_us_ensure_real(), at '0'```
Blender 2.83 compiled with last source code at 13/04/2020 11:48 Windows 10 64 bits - RTX2080TI After unlink [with setting users to zero -- {key Shift click}] several times the same image appears an assert. I could replicate several times the same crash [2020-04-13 11-47-29.mp4](https://archive.blender.org/developer/F8468769/2020-04-13_11-47-29.mp4) Here the call stack of the crash. ```ERROR (bke.lib_id): D:\MyBlender\BlenderDEV\blender\source\blender\blenkernel\intern\lib_id.c:262 id_us_ensure_real: ID user count error: IMgpobj_textures.jpg (from '[Main]') 20: BLI_system_backtrace - 0x7FF73E6933D0 19: id_us_ensure_real - 0x7FF7377301D0 18: ED_space_image_set - 0x7FF738CECAD0 17: rna_SpaceImageEditor_image_set - 0x7FF7381CDFB0 16: SpaceImageEditor_image_set - 0x7FF73819F670 15: RNA_property_pointer_set - 0x7FF737FEA6D0 14: template_ID_set_property_cb - 0x7FF738BA3670 13: ui_apply_but_funcs_after - 0x7FF738B6D0B0 12: ui_handler_region_menu - 0x7FF738B84030 11: wm_handler_ui_call - 0x7FF737B5E3C0 10: wm_handlers_do_intern - 0x7FF737B5FF20 9: wm_handlers_do - 0x7FF737B5E9E0 8: wm_event_do_handlers - 0x7FF737B59590 7: WM_main - 0x7FF737B2FD50 6: main - 0x7FF7373A7930 5: invoke_main - 0x7FF73E930510 4: __scrt_common_main_seh - 0x7FF73E9302C0 3: __scrt_common_main - 0x7FF73E9302A0 2: mainCRTStartup - 0x7FF73E9305D0 1: BaseThreadInitThunk - 0x7FF9DA4C7BC0 0: RtlUserThreadStart - 0x7FF9DBCECEB0 BLI_assert failed: D:\MyBlender\BlenderDEV\blender\source\blender\blenkernel\intern\lib_id.c:263, id_us_ensure_real(), at '0'```
Author
Member

Added subscriber: @antoniov

Added subscriber: @antoniov
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Cannot really reproduce here

System Information
Operating system: Linux-5.5.13-200.fc31.x86_64-x86_64-with-fedora-31-Thirty_One 64 Bits
Graphics card: GeForce GTX 970M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.64
version: 2.83 (sub 13), branch: master (modified), commit date: 2020-04-14 07:46, hash: b2c2d7b7f1

That being said, for me, the Image does not get zero users immediately though (when unlinking from the Image Editor)

Cannot really reproduce here **System Information** Operating system: Linux-5.5.13-200.fc31.x86_64-x86_64-with-fedora-31-Thirty_One 64 Bits Graphics card: GeForce GTX 970M/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 440.64 version: 2.83 (sub 13), branch: master (modified), commit date: 2020-04-14 07:46, hash: `b2c2d7b7f1` That being said, for me, the Image does not get zero users immediately though (when unlinking from the Image Editor)
Author
Member

@lichtwerk Can you try with this file?

SimpleFile.blend

  1. Open the file
  2. Select Image->Invert->Invert Image Colors
  3. Assert crash! BLI_assert failed: D:\MyBlender\BlenderDEV\blender\source\blender\editors\space_image\image_undo.c:670, uhandle_add(), at 'uh->iuser.scene == ((void *)0)'

It looks all errors are related to Undo.

@lichtwerk Can you try with this file? [SimpleFile.blend](https://archive.blender.org/developer/F8474281/SimpleFile.blend) 1) Open the file 2) Select Image->Invert->Invert Image Colors 3) Assert crash! `BLI_assert failed: D:\MyBlender\BlenderDEV\blender\source\blender\editors\space_image\image_undo.c:670, uhandle_add(), at 'uh->iuser.scene == ((void *)0)'` It looks all errors are related to Undo.
Member

Will check in a bit (above assert is probably related to ca717f0489)

Will check in a bit (above assert is probably related to ca717f0489)

This issue was referenced by f250b1f5a0

This issue was referenced by f250b1f5a007a85a646a809a29b706e814f4cf32
Member

@antoniov : could you check with {D7435}? (I mean also the unlinking issues?)

@antoniov : could you check with {[D7435](https://archive.blender.org/developer/D7435)}? (I mean also the unlinking issues?)
Member

@antoniov: I have committed f250b1f5a0 now, could you check if this is still an issue? [the unlinking?]

@antoniov: I have committed f250b1f5a0 now, could you check if this is still an issue? [the unlinking?]
Author
Member

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

Changed status from 'Needs Triage' to: 'Resolved'
Antonio Vazquez self-assigned this 2020-04-15 18:03:04 +02:00
Author
Member

Yes, it's solved!

Yes, it's solved!

Added subscriber: @iss

Added subscriber: @iss

Ah, this is reported by @antoniov.. I was about to say that I am not sure what exactly you were fixing, because I am missing steps.

In any case, I can still make this crash:

Load image in image editor

  • Shift+click on unlink button
  • switch to 3D viewport
  • Switch back to image editor
  • Repeat steps.
>	blender.exe!id_us_ensure_real(ID * id) Line 265	C

 	blender.exe!ED_space_image_set(Main * bmain, SpaceImage * sima, Object * obedit, Image * ima, bool automatic) Line 83	C
 	blender.exe!rna_SpaceImageEditor_image_set(PointerRNA * ptr, PointerRNA value, ReportList * UNUSED_reports) Line 1487	C
 	blender.exe!SpaceImageEditor_image_set(PointerRNA * ptr, PointerRNA value, ReportList * reports) Line 887	C
 	blender.exe!RNA_property_pointer_set(PointerRNA * ptr, PropertyRNA * prop, PointerRNA ptr_value, ReportList * reports) Line 3717	C
 	blender.exe!template_ID_set_property_cb(bContext * C, void * arg_template, void * item) Line 339	C
 	blender.exe!ui_apply_but_funcs_after(bContext * C) Line 911	C
 	blender.exe!ui_handler_region_menu(bContext * C, const wmEvent * event, void * UNUSED_userdata) Line 10747	C
 	blender.exe!wm_handler_ui_call(bContext * C, wmEventHandler_UI * handler, const wmEvent * event, int always_pass) Line 617	C
 	blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2725	C
 	blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2836	C
 	blender.exe!wm_event_do_handlers(bContext * C) Line 3231	C
 	blender.exe!WM_main(bContext * C) Line 453	C
 	blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 526	C

ERROR (bke.lib_id): C:\Blender-git\1\source\blender\blenkernel\intern\lib_id.c:262 id_us_ensure_real: ID user count error: IMUntitled.png (from '[Main]')

Ah, this is reported by @antoniov.. I was about to say that I am not sure what exactly you were fixing, because I am missing steps. In any case, I can still make this crash: Load image in image editor - Shift+click on unlink button - switch to 3D viewport - Switch back to image editor - Repeat steps. ``` > blender.exe!id_us_ensure_real(ID * id) Line 265 C blender.exe!ED_space_image_set(Main * bmain, SpaceImage * sima, Object * obedit, Image * ima, bool automatic) Line 83 C blender.exe!rna_SpaceImageEditor_image_set(PointerRNA * ptr, PointerRNA value, ReportList * UNUSED_reports) Line 1487 C blender.exe!SpaceImageEditor_image_set(PointerRNA * ptr, PointerRNA value, ReportList * reports) Line 887 C blender.exe!RNA_property_pointer_set(PointerRNA * ptr, PropertyRNA * prop, PointerRNA ptr_value, ReportList * reports) Line 3717 C blender.exe!template_ID_set_property_cb(bContext * C, void * arg_template, void * item) Line 339 C blender.exe!ui_apply_but_funcs_after(bContext * C) Line 911 C blender.exe!ui_handler_region_menu(bContext * C, const wmEvent * event, void * UNUSED_userdata) Line 10747 C blender.exe!wm_handler_ui_call(bContext * C, wmEventHandler_UI * handler, const wmEvent * event, int always_pass) Line 617 C blender.exe!wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2725 C blender.exe!wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2836 C blender.exe!wm_event_do_handlers(bContext * C) Line 3231 C blender.exe!WM_main(bContext * C) Line 453 C blender.exe!main(int argc, const unsigned char * * UNUSED_argv_c) Line 526 C ``` ERROR (bke.lib_id): C:\Blender-git\1\source\blender\blenkernel\intern\lib_id.c:262 id_us_ensure_real: ID user count error: IMUntitled.png (from '[Main]')
Author
Member

I tested only the Imge Invert crash... need to test the unlink again.

I tested only the Imge Invert crash... need to test the unlink again.
Member

Changed status from 'Resolved' to: 'Confirmed'

Changed status from 'Resolved' to: 'Confirmed'
Member

Can also confirm the unlinking issue [I wasnt actually using {key Shift click} to set users to zero]... checking on this...

Can also confirm the unlinking issue [I wasnt actually using {key Shift click} to set users to zero]... checking on this...
Member

Added subscriber: @mont29

Added subscriber: @mont29
Member

Looks like this has been around for longer...

When we set an Image for Image Editor, the Image ID is flagged LIB_TAG_EXTRAUSER_SET
When we unlink with zero users this flag is apparently not cleared.
This in turn leads to the Assert mentioned here because the Image has zero users and it is kind of expected to have the extra user...

@mont29: on shaky ground when it comes to usercount, but should the flage be cleared here?
P1342: T75675_snippet



diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 6f6a4a1718a..bd2364a5707 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -536,6 +536,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
 
       if (id && CTX_wm_window(C)->eventstate->shift) {
         /* only way to force-remove data (on save) */
+        id->tag &= ~LIB_TAG_EXTRAUSER_SET;
         id_fake_user_clear(id);
         id->us = 0;
       }
Looks like this has been around for longer... When we set an Image for Image Editor, the Image ID is flagged `LIB_TAG_EXTRAUSER_SET` When we unlink with zero users this flag is apparently not cleared. This in turn leads to the Assert mentioned here because the Image has zero users and it is kind of expected to have the extra user... @mont29: on shaky ground when it comes to usercount, but should the flage be cleared here? [P1342: T75675_snippet](https://archive.blender.org/developer/P1342.txt) ``` diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6f6a4a1718a..bd2364a5707 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -536,6 +536,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) if (id && CTX_wm_window(C)->eventstate->shift) { /* only way to force-remove data (on save) */ + id->tag &= ~LIB_TAG_EXTRAUSER_SET; id_fake_user_clear(id); id->us = 0; } ```
Philipp Oeser changed title from Image editor assert when image is unlinked to Image editor assert when image is unlinked [with setting users to zero] 2020-04-16 15:51:34 +02:00

@lichtwerk please use instead id_us_clear_real(). Otherwise this fix sounds good (though a proper fix would be to move this to modern code, and actually delete the ID...).

@lichtwerk please use instead `id_us_clear_real()`. Otherwise this fix sounds good (though a proper fix would be to move this to modern code, and actually delete the ID...).

This issue was referenced by 8cb10c124e

This issue was referenced by 8cb10c124efebc27a7451f3d3a4c62d23c3927b5
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'

Added subscriber: @ChristopherAnderssarian

Added subscriber: @ChristopherAnderssarian
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#75675
No description provided.