Lambda as scene_update_pre handler may crash Blender upon unload #42005

Closed
opened 2014-09-29 11:48:05 +02:00 by inactive account · 7 comments

System Information
Windows 7 64-bit, running Blender 2.72 RC:

  Blender 2.72 (sub 0)
      build date: 2014-09-23
      build time: 21:13:05
      build commit date: 2014-09-23
      build commit time: 18:40
      build hash: eb464ee
      build platform: Windows:32bit
      build type: Release

Description of error
Blender crashes (without any error) when unloading a Blend file that registered a lambda function. There are a few "requirements" for this issue:

  • The registered function must live in a file external to Blender.
  • The function must be called via a lambda expression.

Here is an example:

"""handler_crash.py"""
import bpy
def echo():
    print("echo")
    return 5
bpy.app.handlers.scene_update_pre.append(lambda _: echo())

Then in the script window in Blender:

import bpy
import sys
sys.path.append(bpy.path.abspath('//'))
  • This imports the above script. If the script is placed here, Blender handles it properly.
  • However, by importing it, this bug manifests itself.
import handler_crash

This will crash Blender

bpy.ops.wm.read_homefile()

Exact steps for others to reproduce the error

  1. Save the attached Blend file and .py file
  2. Open the Blend file
  3. Press [ALT] + - [x] to run the script
  4. See crash

handler_crash.py

handler_crash.blend

**System Information** Windows 7 64-bit, running Blender 2.72 RC: ``` Blender 2.72 (sub 0) build date: 2014-09-23 build time: 21:13:05 build commit date: 2014-09-23 build commit time: 18:40 build hash: eb464ee build platform: Windows:32bit build type: Release ``` **Description of error** Blender crashes (without any error) when unloading a Blend file that registered a lambda function. There are a few "requirements" for this issue: - The registered function must live in a file external to Blender. - The function must be called via a lambda expression. Here is an example: ``` """handler_crash.py""" import bpy ``` ``` def echo(): print("echo") return 5 ``` ``` bpy.app.handlers.scene_update_pre.append(lambda _: echo()) ``` Then in the script window in Blender: ``` import bpy import sys sys.path.append(bpy.path.abspath('//')) ``` - This imports the above script. If the script is placed here, Blender handles it properly. - However, by importing it, this bug manifests itself. ``` import handler_crash ``` # This will crash Blender ``` bpy.ops.wm.read_homefile() ``` **Exact steps for others to reproduce the error** 1. Save the attached Blend file and .py file 2. Open the Blend file 3. Press [ALT] + - [x] to run the script 4. See crash [handler_crash.py](https://archive.blender.org/developer/F113553/handler_crash.py) [handler_crash.blend](https://archive.blender.org/developer/F113554/handler_crash.blend)

Changed status to: 'Open'

Changed status to: 'Open'

Added subscriber: @sybrenstuvel

Added subscriber: @sybrenstuvel

PS: The lambda expression seems to be important to reproduce this bug. When using a regular function, Blender doesn't crash.

PS: The lambda expression seems to be important to reproduce this bug. When using a regular function, Blender doesn't crash.
Campbell Barton was assigned by Bastien Montagne 2014-09-29 12:27:33 +02:00

This issue was referenced by cf38b933f3

This issue was referenced by cf38b933f3408b7f45d0e0e378d8aefb23bd4f6c

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit cf38b933f3.

Closed by commit cf38b933f3.

This issue was referenced by 201abb4946

This issue was referenced by 201abb4946a03fd1df5e7be2c766154a8f6fa198
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blender/blender#42005
No description provided.