Crash opening 2.78 file and switching workspace #55174

Closed
opened 2018-05-24 10:08:55 +02:00 by Adam Latchem · 9 comments

d7824de8e44e8620ebfb6f0971d4136198ab9bb8
MacOS 10.13

Hi - if I open certain Blender 2.78 files in Blender 2.80 I encounter a NULL pointer when changing workspaces.

To reproduce:

  1. open Sun.blend from github
  2. switch to the compositor workspace
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x70)
  * frame #0: 0x000000010017a3b0 blender`WM_toolsystem_mode_from_spacetype(workspace=0x000060c0001e7b08, scene=0x000000012601b208, sa=0x0000604000162b88, spacetype=1) at wm_toolsystem.c:363

frame #1: 0x000000010017b357 blenderWM_toolsystem_refresh_screen_area(workspace=0x000060c0001e7b08, scene=0x000000012601b208, sa=0x0000604000162b88) at wm_toolsystem.c:407 frame #2: 0x0000000100779dce blenderED_area_initialize(wm=0x000000011f683b98, win=0x000000011f683d38, sa=0x0000604000162b88) at area.c:1468
frame #3: 0x00000001007887ab blenderED_screen_refresh(wm=0x000000011f683b98, win=0x000000011f683d38) at screen_edit.c:816 frame #4: 0x000000010078a135 blenderscreen_change_update(C=0x00006080000e0288, win=0x000000011f683d38, sc=0x000000011fa838a8) at screen_edit.c:1232
frame #5: 0x000000010079a0d0 blenderED_workspace_change(workspace_new=0x000060c0001e7b08, C=0x00006080000e0288, wm=0x000000011f683b98, win=0x000000011f683d38) at workspace_edit.c:199 frame #6: 0x00000001001474be blenderwm_event_do_notifiers(C=0x00006080000e0288) at wm_event_system.c:387
frame #7: 0x0000000100142b00 blenderWM_main(C=0x00006080000e0288) at wm.c:548 frame #8: 0x000000010013ce8c blendermain(argc=1, argv=0x00007ffeefbff4a8) at creator.c:514
frame #9: 0x00007fff7709a015 libdyld.dylibstart + 1 frame #10: 0x00007fff7709a015 libdyld.dylibstart + 1```


There is a simple tactical fix which I will attach as a patch. It simply checks for a NULL view_layer in the workspace. However the file reading logic may need to spot the missing workspace objects and add them - if I open the file then immediately save it from 2.8 and reopen it the NULL does not happen. This is because write_file_handle calls write_workspace. I notice this happens for the in memory undo stack file when a file is read or something is pushed to the stack so perhaps similar logic could be added to upgrade the 2.78 files?
d7824de8e44e8620ebfb6f0971d4136198ab9bb8 MacOS 10.13 Hi - if I open certain Blender 2.78 files in Blender 2.80 I encounter a NULL pointer when changing workspaces. To reproduce: 1. open [Sun.blend from github ](https://github.com/adamlatchem/dominoesAtDusk/blob/9c8627146a8c118b12c154d4f4cc8949b0c50820/lib/objects/Sun.blend) 2. switch to the compositor workspace ```(lldb) thread backtrace * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x70) * frame #0: 0x000000010017a3b0 blender`WM_toolsystem_mode_from_spacetype(workspace=0x000060c0001e7b08, scene=0x000000012601b208, sa=0x0000604000162b88, spacetype=1) at wm_toolsystem.c:363 ``` frame #1: 0x000000010017b357 blender`WM_toolsystem_refresh_screen_area(workspace=0x000060c0001e7b08, scene=0x000000012601b208, sa=0x0000604000162b88) at wm_toolsystem.c:407 frame #2: 0x0000000100779dce blender`ED_area_initialize(wm=0x000000011f683b98, win=0x000000011f683d38, sa=0x0000604000162b88) at area.c:1468 frame #3: 0x00000001007887ab blender`ED_screen_refresh(wm=0x000000011f683b98, win=0x000000011f683d38) at screen_edit.c:816 frame #4: 0x000000010078a135 blender`screen_change_update(C=0x00006080000e0288, win=0x000000011f683d38, sc=0x000000011fa838a8) at screen_edit.c:1232 frame #5: 0x000000010079a0d0 blender`ED_workspace_change(workspace_new=0x000060c0001e7b08, C=0x00006080000e0288, wm=0x000000011f683b98, win=0x000000011f683d38) at workspace_edit.c:199 frame #6: 0x00000001001474be blender`wm_event_do_notifiers(C=0x00006080000e0288) at wm_event_system.c:387 frame #7: 0x0000000100142b00 blender`WM_main(C=0x00006080000e0288) at wm.c:548 frame #8: 0x000000010013ce8c blender`main(argc=1, argv=0x00007ffeefbff4a8) at creator.c:514 frame #9: 0x00007fff7709a015 libdyld.dylib`start + 1 frame #10: 0x00007fff7709a015 libdyld.dylib`start + 1``` ``` There is a simple tactical fix which I will attach as a patch. It simply checks for a NULL view_layer in the workspace. However the file reading logic may need to spot the missing workspace objects and add them - if I open the file then immediately save it from 2.8 and reopen it the NULL does not happen. This is because write_file_handle calls write_workspace. I notice this happens for the in memory undo stack file when a file is read or something is pushed to the stack so perhaps similar logic could be added to upgrade the 2.78 files?
Author

Added subscriber: @adamlatchem-2

Added subscriber: @adamlatchem-2
Author

Here is my suggested tactical fix

index d734fee05ae..2764123011c 100644
    - a/source/blender/windowmanager/intern/wm_toolsystem.c
+++ b/source/blender/windowmanager/intern/wm_toolsystem.c
@@ -358,15 +358,17 @@ int WM_toolsystem_mode_from_spacetype(
  switch (spacetype) {
          case SPACE_VIEW3D:
          {
+                       mode = CTX_MODE_OBJECT;
+
                  /* 'sa' may be NULL in this case. */
                  ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene);
- Object *obact = OBACT(view_layer);
- if (obact != NULL) {
- Object *obedit = OBEDIT_FROM_OBACT(obact);
- mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode);
- }
- else {
- mode = CTX_MODE_OBJECT;
+                       if (view_layer != NULL)
+                       {
+                               Object *obact = OBACT(view_layer);
+                               if (obact != NULL) {
+                                       Object *obedit = OBEDIT_FROM_OBACT(obact);
+                                       mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode);
+                               }
                  }
                  break;
          }
Here is my suggested tactical fix ```diff --git a/source/blender/windowmanager/intern/wm_toolsystem.c b/source/blender/windowmanager/intern/wm_toolsystem.c index d734fee05ae..2764123011c 100644 - a/source/blender/windowmanager/intern/wm_toolsystem.c +++ b/source/blender/windowmanager/intern/wm_toolsystem.c @@ -358,15 +358,17 @@ int WM_toolsystem_mode_from_spacetype( ``` switch (spacetype) { case SPACE_VIEW3D: { ``` + mode = CTX_MODE_OBJECT; + ``` /* 'sa' may be NULL in this case. */ ViewLayer *view_layer = BKE_workspace_view_layer_get(workspace, scene); ``` - Object *obact = OBACT(view_layer); - if (obact != NULL) { - Object *obedit = OBEDIT_FROM_OBACT(obact); - mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode); - } - else { - mode = CTX_MODE_OBJECT; + if (view_layer != NULL) + { + Object *obact = OBACT(view_layer); + if (obact != NULL) { + Object *obedit = OBEDIT_FROM_OBACT(obact); + mode = CTX_data_mode_enum_ex(obedit, obact, obact->mode); + } ``` } break; } ```

Added subscribers: @ideasman42, @JoshuaLeung

Added subscribers: @ideasman42, @JoshuaLeung
Campbell Barton was assigned by Joshua Leung 2018-05-24 12:34:06 +02:00

@ideasman42 Looks like one of the toolsystem <-> workspace things you were working on last week.

@adamlatchem-2 Technically we haven't opened the tracker for 2.8 user bug reports yet. We're currently dealing with a large number of critical bugs from the Spring team that need to get addressed first.

@ideasman42 Looks like one of the toolsystem <-> workspace things you were working on last week. @adamlatchem-2 Technically we haven't opened the tracker for 2.8 user bug reports yet. We're currently dealing with a large number of critical bugs from the Spring team that need to get addressed first.

This issue was referenced by blender/blender@03a80facfc

This issue was referenced by blender/blender@03a80facfc78178632086179e36f1c67128d5c09

Added subscriber: @brecht

Added subscriber: @brecht

The real problem here is that the view layer should not be NULL, if that's the case lots of other things can break too.

The real problem here is that the view layer should not be NULL, if that's the case lots of other things can break too.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author

Thanks for the more comprehensive fix Brecht.

Thanks for the more comprehensive fix Brecht.
This repo is archived. You cannot comment on issues.
No Milestone
No Assignees
4 Participants
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: archive/blender-file#55174
No description provided.