Crash while editing keymap entry (MacOS only) #119014

Closed
opened 2024-03-02 22:32:15 +01:00 by Sean Kim · 13 comments
Member

System Information
Operating system: macOS Sonoma 14.2
Processor: 2.6 GHz 6-Core Intel Core i7
Graphics card: AMD Radeon Pro 530M 4 GB

Blender Version
Broken: Current main, 434759d3339
Worked: 4.1.0, 3d6bb6ce04ad, blender-v4.1-release, 2024-02-29

Short description of error
Blender encounters a segfault when editing the Identifier property in the keymap preferences.

Exact steps for others to reproduce the error

  1. Open default startup
  2. Open preferences
  3. Click Keymap
  4. Select any entry (e.g. Window -> New File)
  5. Click on identifier property

crash.txt

# Blender 4.2.0, Unknown revision
bpy.data.window_managers["WinMan"]. = True  # Property
bpy.data.window_managers["WinMan"]. = True  # Property

# backtrace
0   Blender                             0x000000010ee82fc7 BLI_system_backtrace + 55
1   Blender                             0x000000010e3bd767 _ZL16sig_handle_crashi + 359
2   libsystem_platform.dylib            0x00007ff815f3437d _sigtramp + 29
3   ???                                 0x0000000000000000 0x0 + 0
4   Blender                             0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210
5   Blender                             0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210
6   Blender                             0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210
7   Blender                             0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210
8   Blender                             0x000000010f78f876 _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1174
9   Blender                             0x000000010f78e71d _Z34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsb + 1245
10  Blender                             0x000000010f75f0d0 _Z19ui_searchbox_updateP8bContextP7ARegionP5uiButb + 448
11  Blender                             0x000000010f71d795 _ZL21button_activate_stateP8bContextP5uiBut19uiHandleButtonState + 1733
12  Blender                             0x000000010f729c33 _ZL13ui_do_but_TEXP8bContextP7uiBlockP5uiButP18uiHandleButtonDataPK7wmEvent + 243
13  Blender                             0x000000010f725c98 _ZL12ui_do_buttonP8bContextP7uiBlockP5uiButPK7wmEvent + 2104
14  Blender                             0x000000010f723400 _ZL22ui_handle_button_eventP8bContextPK7wmEventP5uiBut + 1408
15  Blender                             0x000000010f7323fd _ZL17ui_region_handlerP8bContextPK7wmEventPv + 269
16  Blender                             0x000000010eef53ec _ZL21wm_handlers_do_internP8bContextP8wmWindowP7wmEventP8ListBase + 3612
17  Blender                             0x000000010eef3f30 _ZL14wm_handlers_doP8bContextP7wmEventP8ListBase + 48
18  Blender                             0x000000010eef3661 _Z20wm_event_do_handlersP8bContext + 3857
19  Blender                             0x000000010eee6fa0 _Z7WM_mainP8bContext + 32
20  Blender                             0x000000010e3b96cd main + 781
21  dyld                                0x00007ff815b7b386 start + 1942

# Python backtrace

**System Information** Operating system: macOS Sonoma 14.2 Processor: 2.6 GHz 6-Core Intel Core i7 Graphics card: AMD Radeon Pro 530M 4 GB **Blender Version** Broken: Current `main`, `434759d3339` Worked: 4.1.0, `3d6bb6ce04ad`, blender-v4.1-release, 2024-02-29 **Short description of error** Blender encounters a segfault when editing the `Identifier` property in the keymap preferences. **Exact steps for others to reproduce the error** 1. Open default startup 2. Open preferences 3. Click Keymap 4. Select any entry (e.g. Window -> New File) 5. Click on identifier property ### crash.txt ``` # Blender 4.2.0, Unknown revision bpy.data.window_managers["WinMan"]. = True # Property bpy.data.window_managers["WinMan"]. = True # Property # backtrace 0 Blender 0x000000010ee82fc7 BLI_system_backtrace + 55 1 Blender 0x000000010e3bd767 _ZL16sig_handle_crashi + 359 2 libsystem_platform.dylib 0x00007ff815f3437d _sigtramp + 29 3 ??? 0x0000000000000000 0x0 + 0 4 Blender 0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210 5 Blender 0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210 6 Blender 0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210 7 Blender 0x000000010f78f89a _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1210 8 Blender 0x000000010f78f876 _ZNSt3__111__introsortINS_17_ClassicAlgPolicyERZ34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsbE3$_1PNS_10unique_ptrI14CollItemSearchNS_14default_deleteISD_EEEEEEvT1_SI_T0_NS_15iterator_traitsISI_E15difference_typeE + 1174 9 Blender 0x000000010f78e71d _Z34ui_rna_collection_search_update_fnPK8bContextPvPKcP13uiSearchItemsb + 1245 10 Blender 0x000000010f75f0d0 _Z19ui_searchbox_updateP8bContextP7ARegionP5uiButb + 448 11 Blender 0x000000010f71d795 _ZL21button_activate_stateP8bContextP5uiBut19uiHandleButtonState + 1733 12 Blender 0x000000010f729c33 _ZL13ui_do_but_TEXP8bContextP7uiBlockP5uiButP18uiHandleButtonDataPK7wmEvent + 243 13 Blender 0x000000010f725c98 _ZL12ui_do_buttonP8bContextP7uiBlockP5uiButPK7wmEvent + 2104 14 Blender 0x000000010f723400 _ZL22ui_handle_button_eventP8bContextPK7wmEventP5uiBut + 1408 15 Blender 0x000000010f7323fd _ZL17ui_region_handlerP8bContextPK7wmEventPv + 269 16 Blender 0x000000010eef53ec _ZL21wm_handlers_do_internP8bContextP8wmWindowP7wmEventP8ListBase + 3612 17 Blender 0x000000010eef3f30 _ZL14wm_handlers_doP8bContextP7wmEventP8ListBase + 48 18 Blender 0x000000010eef3661 _Z20wm_event_do_handlersP8bContext + 3857 19 Blender 0x000000010eee6fa0 _Z7WM_mainP8bContext + 32 20 Blender 0x000000010e3b96cd main + 781 21 dyld 0x00007ff815b7b386 start + 1942 # Python backtrace ```
Sean Kim added the
Severity
Normal
Type
Report
Status
Needs Triage
labels 2024-03-02 22:32:15 +01:00
Author
Member

Threw an assert in the sort comparison function here in interface_utils.cc , a is nullptr occasionally

      std::sort(
          items_list.begin(),
          items_list.end(),
          [](const std::unique_ptr<CollItemSearch> &a, const std::unique_ptr<CollItemSearch> &b) {
            return BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0;
          });

Suspect it's b9ed6ce0a5d12ab706b14ecdab63415faf87054d causing this but because this is before the git-lfs change I haven't spent time setting up an env with those libraries around still.

Threw an assert in the sort comparison function here in `interface_utils.cc` , a is `nullptr` occasionally ``` std::sort( items_list.begin(), items_list.end(), [](const std::unique_ptr<CollItemSearch> &a, const std::unique_ptr<CollItemSearch> &b) { return BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0; }); ``` Suspect it's `b9ed6ce0a5d12ab706b14ecdab63415faf87054d` causing this but because this is before the git-lfs change I haven't spent time setting up an env with those libraries around still.

Can't confirm.

Can't confirm.
Author
Member

Hmm, I wonder if I have a weird cached file or something. I'll try a clean build in with factory startup tomorrow.

Hmm, I wonder if I have a weird cached file or something. I'll try a clean build in with factory startup tomorrow.

Also can't confirm on Linux.

Also can't confirm on Linux.
Author
Member

Ok, I removed any build artifacts that were in the parent directly (build_darwin_*), performed

make update
make lite

ran Blender with ../build_darwin_lite/bin/Blender.app/Contents/MacOS/Blender --factory-startup and I still get the same crash.

I'm also able to replicate this on the current daily 4.2.0 build (b0daa792d3b5) for Intel Mac from the builds page.

Ok, I removed any build artifacts that were in the parent directly (`build_darwin_*`), performed ``` make update make lite ``` ran Blender with `../build_darwin_lite/bin/Blender.app/Contents/MacOS/Blender --factory-startup` and I still get the same crash. I'm also able to replicate this on the current daily `4.2.0` build (`b0daa792d3b5`) for Intel Mac from the builds page.
Member

Unable to confirm either in debug build 8c16b612ca8820503c455eca4603240e6b9bb503 (on Windows btw)

Unable to confirm either in debug build `8c16b612ca8820503c455eca4603240e6b9bb503` (on Windows btw)

Will check on Mac then, perhaps this is platform specific.

Will check on Mac then, perhaps this is platform specific.

Can indeed confirm on Mac

Can indeed confirm on Mac
Richard Antalik changed title from Crash while editing keymap entry to Crash while editing keymap entry (MacOS only) 2024-03-06 19:47:48 +01:00
Author
Member

I think I've nailed down the issue to being something in the std::sort function - I tried swapping out blender's Vector class for std::vector in that particular code block and still run into the same crash where one of the unique_ptrs suddenly is nullptr after about 2k iterations of the comparison function.

Observing all the pointers prior to the sort being called shows no signs of nullptr

I think I've nailed down the issue to being something in the `std::sort` function - I tried swapping out blender's `Vector` class for `std::vector` in that particular code block and still run into the same crash where one of the `unique_ptr`s suddenly is `nullptr` after about 2k iterations of the comparison function. Observing all the pointers prior to the sort being called shows no signs of `nullptr`
Contributor

No exception is thrown, if to change comparator to:

return a->name.compare(b->name);

I suspect that some values in a list with condition BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0
drives Mac's std::sort implementation crazy.

While writing this also find out that if to change <= 0 to < 0 it also works, but I don't know reasoning behind expression.

No exception is thrown, if to change comparator to: ``` return a->name.compare(b->name); ``` I suspect that some values in a list with condition `BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0` drives Mac's `std::sort` implementation crazy. While writing this also find out that if to change `<= 0` to `< 0` it also works, but I don't know reasoning behind expression.
Author
Member

This discussion on the libc++ forum seems possibly related: https://discourse.llvm.org/t/rfc-strict-weak-ordering-checks-in-the-debug-libc/70217

This discussion on the libc++ forum seems possibly related: https://discourse.llvm.org/t/rfc-strict-weak-ordering-checks-in-the-debug-libc/70217
Author
Member

No exception is thrown, if to change comparator to:

return a->name.compare(b->name);

I suspect that some values in a list with condition BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0
drives Mac's std::sort implementation crazy.

While writing this also find out that if to change <= 0 to < 0 it also works, but I don't know reasoning behind expression.

This discussion seems relevant: https://reviews.llvm.org/D146421, specifically the following bit

More specifically, std::sort assumes that the comparison predicate is a
strict weak order (which is a pre-condition to the algorithm).

My guess is that libc++'s particular implementation of std::sort takes advantage of strict weak ordering somewhere that causes this odd behavior.

> No exception is thrown, if to change comparator to: > ``` > return a->name.compare(b->name); > ``` > I suspect that some values in a list with condition `BLI_strcasecmp_natural(a->name.c_str(), b->name.c_str()) <= 0` > drives Mac's `std::sort` implementation crazy. > > While writing this also find out that if to change `<= 0` to `< 0` it also works, but I don't know reasoning behind expression. This discussion seems relevant: https://reviews.llvm.org/D146421, specifically the following bit > More specifically, std::sort assumes that the comparison predicate is a strict weak order (which is a pre-condition to the algorithm). My guess is that `libc++`'s particular implementation of `std::sort` takes advantage of strict weak ordering somewhere that causes this odd behavior.
Author
Member

#93285 had a similar issue - I think the correct move here is to apply the change to use < over <= and then clean up any other usage of this elsewhere in the codebase since this is out of spec with the requirements on Compare

Establishes strict weak ordering relation with the following properties:
For all a, comp(a, a) == false.
If comp(a, b) == true then comp(b, a) == false.
if comp(a, b) == true and comp(b, c) == true then comp(a, c) == true.

https://projects.blender.org/blender/blender/issues/93285 had a similar issue - I think the correct move here is to apply the change to use `<` over `<=` and then clean up any other usage of this elsewhere in the codebase since this is out of spec with the requirements on [Compare](https://en.cppreference.com/w/cpp/named_req/Compare) > Establishes strict weak ordering relation with the following properties: For all a, comp(a, a) == false. If comp(a, b) == true then comp(b, a) == false. if comp(a, b) == true and comp(b, c) == true then comp(a, c) == true.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-03-11 16:31:24 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
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#119014
No description provided.