Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when appending None to Collection types #1680

Open
reinecke opened this issue Nov 16, 2023 · 3 comments
Open

Segmentation fault when appending None to Collection types #1680

reinecke opened this issue Nov 16, 2023 · 3 comments
Labels
bug A problem, flaw, or broken functionality. good first issue If you're looking for a way to contribute, but not sure where to start. This is a good first issue.

Comments

@reinecke
Copy link
Collaborator

Bug Report

Incorrect Functionality and General Questions

When None is passed to the append method on a collection, the python interpreter exits with a Segmentation Fault. I first encountered this in Track, but traced the behavior up the object hierarchy to Collection and verified in Stack as well.

Track

% python
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import opentimelineio as otio
>>> track = otio.schema.Track()
>>> track.append(None)
zsh: segmentation fault  python

Stack

% python
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import opentimelineio as otio
>>> stack = otio.schema.Stack()
>>> stack.append(None)
zsh: segmentation fault  python

Composition

% python
Python 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import opentimelineio as otio
>>> composition = otio.core.Composition()
>>> composition.append(None)
zsh: segmentation fault  python

SerializableCollection

Interestingly, SerializableCollection behaves differently, but still incorrectly:

>>> import opentimelineio as otio
>>> bin = otio.schema.SerializableCollection()
>>> bin.append(None)
>>> bin
otio.schema.SerializableCollection(name='', children=[None], metadata={})

To Reproduce

  1. Operating system: macOS 13.6.1 (22G313) Apple M2
  2. Python version: 3.11.5
  3. OpenTimelineIO release version or commit hash: b680372
  4. Compiler information:
    Apple clang version 15.0.0 (clang-1500.0.40.1)
    Target: arm64-apple-darwin22.6.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Expected Behavior

We should throw a TypeError exception as in the following example:

>>> import opentimelineio as otio
>>> composition = otio.core.Composition()
>>> composition.append("not a Composable")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen _collections_abc>", line 1078, in append
  File "/Users/ereinecke/Projects/github/OpenTimelineIO/.venv/lib/python3.11/site-packages/OpenTimelineIO-0.16.0.dev1-py3.11-macosx-13-arm64.egg/opentimelineio/core/_core_utils.py", line 303, in insert
    self.__internal_insert(
TypeError: __internal_insert(): incompatible function arguments. The following argument types are supported:
    1. (self: opentimelineio._otio.Composition, index: int, item: opentimelineio._otio.Composable) -> None

Invoked with: otio.core.Composition(name='', children=[], source_range=None, metadata={}), 0, 'not a Composable'

Logs

Full crash log from macOS crash report:

-------------------------------------
Translated Report (Full Report Below)
-------------------------------------

Process:               Python [54268]
Path:                  /opt/homebrew/*/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python
Identifier:            org.python.python
Version:               3.11.5 (3.11.5)
Code Type:             ARM-64 (Native)
Parent Process:        zsh [10120]
User ID:               501

Date/Time:             2023-11-16 11:48:25.7105 -0800
OS Version:            macOS 13.6.1 (22G313)
Report Version:        12
Anonymous UUID:        D48FAC32-27A3-28E8-3F9F-CC4F0DBF675B

Sleep/Wake UUID:       ACB5B591-B66F-4C7E-9739-0D1782460EA3

Time Awake Since Boot: 510000 seconds
Time Since Wake:       6869 seconds

System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x00000000000000d0
Exception Codes:       0x0000000000000001, 0x00000000000000d0

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [54268]

VM Region Info: 0xd0 is not in any region.  Bytes before following region: 105553518919472
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-/rwx SM=NUL  ...(unallocated)

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   _otio.cpython-311-darwin.so   	       0x102e3f878 0x102dac000 + 604280
1   _otio.cpython-311-darwin.so   	       0x102e2fe50 0x102dac000 + 540240
2   _otio.cpython-311-darwin.so   	       0x102db8184 0x102dac000 + 49540
3   Python                        	       0x10270f92c cfunction_call + 60
4   Python                        	       0x1026c7e34 _PyObject_MakeTpCall + 128
5   Python                        	       0x1027a0078 _PyEval_EvalFrameDefault + 40660
6   Python                        	       0x102795660 PyEval_EvalCode + 168
7   Python                        	       0x1027e80ec run_eval_code_obj + 84
8   Python                        	       0x1027e8050 run_mod + 112
9   Python                        	       0x1027e8384 PyRun_InteractiveOneObjectEx + 548
10  Python                        	       0x1027e7748 _PyRun_InteractiveLoopObject + 288
11  Python                        	       0x1027e71e8 _PyRun_AnyFileObject + 76
12  Python                        	       0x1027ea108 PyRun_AnyFileExFlags + 84
13  Python                        	       0x102802bdc pymain_run_stdin + 160
14  Python                        	       0x102802228 Py_RunMain + 348
15  Python                        	       0x1028034c4 Py_BytesMain + 40
16  dyld                          	       0x18a27ff28 start + 2236


Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000137e04400   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x000000016dc965f0
    x4: 0x000000016dc96298   x5: 0x0000000000000002   x6: 0x0000000000000027   x7: 0x0000000000000005
    x8: 0x0000000000000001   x9: 0x0000000000000087  x10: 0x0000000103197910  x11: 0x0000000000000000
   x12: 0x00000001029a3ee0  x13: 0x00000001029a3ee0  x14: 0x0000000102941780  x15: 0x000000010287e500
   x16: 0x000000018a606940  x17: 0x000000005f5f3230  x18: 0x0000000000000000  x19: 0x0000000000000001
   x20: 0x000000016dc967b0  x21: 0x000000016dc965d8  x22: 0x0000000000000001  x23: 0x0000600002660680
   x24: 0x0000000000000003  x25: 0x00006000008715d8  x26: 0x0000000000000001  x27: 0x0000000102a255d8
   x28: 0x000000010319e800   fp: 0x000000016dc965a0   lr: 0x0000000102e2fe50
    sp: 0x000000016dc96560   pc: 0x0000000102e3f878 cpsr: 0x60001000
   far: 0x00000000000000d0  esr: 0x92000006 (Data Abort) byte read Translation fault

Binary Images:
       0x102168000 -        0x10216bfff org.python.python (3.11.5) <0a04bde3-615c-3696-a606-f5a68271ae34> /opt/homebrew/*/Python.framework/Versions/3.11/Resources/Python.app/Contents/MacOS/Python
       0x102664000 -        0x1028fffff org.python.python (3.11.5, (c) 2001-2023 Python Software Foundation.) <9c7fb383-a104-3ffc-9609-fcf3fcb49c5f> /opt/homebrew/*/Python.framework/Versions/3.11/Python
       0x102434000 -        0x10243bfff readline.cpython-311-darwin.so (*) <58689ef5-193a-3990-9958-4453497030c8> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/readline.cpython-311-darwin.so
       0x102548000 -        0x10254bfff _opcode.cpython-311-darwin.so (*) <66d8c6b3-fb84-36b2-840b-a13797c6d05c> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_opcode.cpython-311-darwin.so
       0x1025fc000 -        0x10263bfff _opentime.cpython-311-darwin.so (*) <c85afeb5-eb15-3dce-9fd8-1555770c0b3d> /Users/USER/*/_opentime.cpython-311-darwin.so
       0x102dac000 -        0x102ebbfff _otio.cpython-311-darwin.so (*) <7a3a83b0-28c6-3956-a4fe-61db74c0620d> /Users/USER/*/_otio.cpython-311-darwin.so
       0x102558000 -        0x10255ffff zlib.cpython-311-darwin.so (*) <b0a5fab2-03c0-36d3-813f-e5e2ad4e028a> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/zlib.cpython-311-darwin.so
       0x10256c000 -        0x10256ffff _bz2.cpython-311-darwin.so (*) <a972cae5-ddce-3c55-b967-641c422e81d8> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_bz2.cpython-311-darwin.so
       0x102594000 -        0x10259bfff _lzma.cpython-311-darwin.so (*) <acfad6cd-7d77-3d16-9671-137661fb202f> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_lzma.cpython-311-darwin.so
       0x102c50000 -        0x102c6ffff liblzma.5.dylib (*) <7c1e4570-c041-3609-be6b-5baca080a220> /opt/homebrew/*/liblzma.5.dylib
       0x1025ac000 -        0x1025b7fff math.cpython-311-darwin.so (*) <c0021831-29bc-3ae0-ac24-f36d3e546ce6> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/math.cpython-311-darwin.so
       0x10257c000 -        0x10257ffff _bisect.cpython-311-darwin.so (*) <0485697b-5f35-363c-bf21-1ca99882739b> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_bisect.cpython-311-darwin.so
       0x1025c4000 -        0x1025c7fff _random.cpython-311-darwin.so (*) <9a40fb5d-035f-3596-bcc6-52ec5b4f06ef> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_random.cpython-311-darwin.so
       0x1025d4000 -        0x1025d7fff _sha512.cpython-311-darwin.so (*) <d5768942-bc77-3e29-817a-cb14ca2bed2c> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_sha512.cpython-311-darwin.so
       0x1025e4000 -        0x1025e7fff _typing.cpython-311-darwin.so (*) <0de32fb1-0c65-3673-a516-8e816433fe23> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_typing.cpython-311-darwin.so
       0x10264c000 -        0x102653fff _csv.cpython-311-darwin.so (*) <f013a63a-17b6-33f4-b86c-7b3c2b0e84c3> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_csv.cpython-311-darwin.so
       0x102d80000 -        0x102d87fff binascii.cpython-311-darwin.so (*) <72a70cad-76ca-37a9-9d53-82eb43b6a615> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/binascii.cpython-311-darwin.so
       0x102d94000 -        0x102d9bfff _struct.cpython-311-darwin.so (*) <fd5ef3bb-abcd-36ad-a5d4-2d9810ecbe69> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_struct.cpython-311-darwin.so
       0x103100000 -        0x10310ffff _socket.cpython-311-darwin.so (*) <5f090c53-f019-3410-a813-12171a9fec3b> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_socket.cpython-311-darwin.so
       0x102fd4000 -        0x102fdbfff select.cpython-311-darwin.so (*) <299158ec-38c8-3acc-bd1d-07edd1305c2d> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/select.cpython-311-darwin.so
       0x102fe8000 -        0x102feffff array.cpython-311-darwin.so (*) <c9f588aa-b900-3eb1-bc2a-4441025b038e> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/array.cpython-311-darwin.so
       0x10313c000 -        0x10314bfff _datetime.cpython-311-darwin.so (*) <db67441a-0f81-3c26-8b31-c20c3edfe3f8> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_datetime.cpython-311-darwin.so
       0x10325c000 -        0x103263fff _hashlib.cpython-311-darwin.so (*) <0a5eaeee-b18c-3e33-bea3-49b89a59d476> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_hashlib.cpython-311-darwin.so
       0x1035cc000 -        0x10380bfff libcrypto.3.dylib (*) <ee435fd4-fc75-3678-8771-44c5f8fce42d> /opt/homebrew/*/libcrypto.3.dylib
       0x10311c000 -        0x103123fff _blake2.cpython-311-darwin.so (*) <bfb55ded-ac7e-3005-aaad-f9c6caee0732> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_blake2.cpython-311-darwin.so
       0x1032b0000 -        0x1032cbfff _ssl.cpython-311-darwin.so (*) <29f60baa-c248-37e3-a081-6d39af52d5cc> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_ssl.cpython-311-darwin.so
       0x103374000 -        0x1033cbfff libssl.3.dylib (*) <10052851-a8b1-309c-ad00-00549cb7a7b9> /opt/homebrew/*/libssl.3.dylib
       0x103278000 -        0x10327bfff _scproxy.cpython-311-darwin.so (*) <cf36ebee-bf47-3e18-8eca-242681790344> /opt/homebrew/*/Python.framework/Versions/3.11/lib/python3.11/lib-dynload/_scproxy.cpython-311-darwin.so
       0x18a27a000 -        0x18a308587 dyld (*) <49204446-242b-3d1e-9704-32f8ac99723e> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=922.8M resident=0K(0%) swapped_out_or_unallocated=922.8M(100%)
Writable regions: Total=1.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.1G(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Kernel Alloc Once                   32K        1 
MALLOC                           215.2M       26 
MALLOC guard page                   96K        5 
MALLOC_MEDIUM (reserved)         480.0M        4         reserved VM address space (unallocated)
MALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)
STACK GUARD                         16K        1 
Stack                             16.0M        1 
VM_ALLOCATE                       8208K        9 
__AUTH                             309K       60 
__AUTH_CONST                      3716K      144 
__DATA                            3326K      166 
__DATA_CONST                      5123K      173 
__DATA_DIRTY                       361K       58 
__LINKEDIT                       804.4M       29 
__OBJC_RO                         66.4M        1 
__OBJC_RW                         2012K        1 
__TEXT                           118.4M      180 
dyld private memory                272K        2 
shared memory                       32K        2 
===========                     =======  ======= 
TOTAL                              2.1G      864 
TOTAL, minus reserved VM space     1.2G      864 



-----------
Full Report
-----------

{"app_name":"Python","timestamp":"2023-11-16 11:48:25.00 -0800","app_version":"3.11.5","slice_uuid":"0a04bde3-615c-3696-a606-f5a68271ae34","build_version":"3.11.5","platform":1,"bundleID":"org.python.python","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 13.6.1 (22G313)","roots_installed":0,"name":"Python","incident_id":"383D4354-DCCC-4950-877E-E86326333093"}
{
  "uptime" : 510000,
  "procRole" : "Unspecified",
  "version" : 2,
  "userID" : 501,
  "deployVersion" : 210,
  "modelCode" : "Mac14,6",
  "coalitionID" : 699,
  "osVersion" : {
    "train" : "macOS 13.6.1",
    "build" : "22G313",
    "releaseType" : "User"
  },
  "captureTime" : "2023-11-16 11:48:25.7105 -0800",
  "incident" : "383D4354-DCCC-4950-877E-E86326333093",
  "pid" : 54268,
  "translated" : false,
  "cpuType" : "ARM-64",
  "roots_installed" : 0,
  "bug_type" : "309",
  "procLaunch" : "2023-11-16 11:41:05.7492 -0800",
  "procStartAbsTime" : 12253525882917,
  "procExitAbsTime" : 12264085001796,
  "procName" : "Python",
  "procPath" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/Resources\/Python.app\/Contents\/MacOS\/Python",
  "bundleInfo" : {"CFBundleShortVersionString":"3.11.5","CFBundleVersion":"3.11.5","CFBundleIdentifier":"org.python.python"},
  "storeInfo" : {"deviceIdentifierForVendor":"66F2CF09-4974-5019-9D20-103EC4CD53C4","thirdParty":true},
  "parentProc" : "zsh",
  "parentPid" : 10120,
  "coalitionName" : "com.googlecode.iterm2",
  "crashReporterKey" : "D48FAC32-27A3-28E8-3F9F-CC4F0DBF675B",
  "responsiblePid" : 1858,
  "codeSigningID" : "org.python.python",
  "codeSigningTeamID" : "",
  "codeSigningFlags" : 570425857,
  "codeSigningValidationCategory" : 10,
  "codeSigningTrustLevel" : 0,
  "wakeTime" : 6869,
  "sleepWakeUUID" : "ACB5B591-B66F-4C7E-9739-0D1782460EA3",
  "sip" : "enabled",
  "vmRegionInfo" : "0xd0 is not in any region.  Bytes before following region: 105553518919472\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "exception" : {"codes":"0x0000000000000001, 0x00000000000000d0","rawCodes":[1,208],"type":"EXC_BAD_ACCESS","signal":"SIGSEGV","subtype":"KERN_INVALID_ADDRESS at 0x00000000000000d0"},
  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":54268},
  "vmregioninfo" : "0xd0 is not in any region.  Bytes before following region: 105553518919472\n      REGION TYPE                    START - END         [ VSIZE] PRT\/MAX SHRMOD  REGION DETAIL\n      UNUSED SPACE AT START\n--->  \n      MALLOC_NANO (reserved)   600018000000-600020000000 [128.0M] rw-\/rwx SM=NUL  ...(unallocated)",
  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
  "faultingThread" : 0,
  "threads" : [{"triggered":true,"id":8020835,"threadState":{"x":[{"value":5232411648},{"value":0},{"value":0},{"value":6136882672},{"value":6136881816},{"value":2},{"value":39},{"value":5},{"value":1},{"value":135},{"value":4346968336},{"value":0},{"value":4338630368,"symbolLocation":0,"symbol":"PyTuple_Type"},{"value":4338630368,"symbolLocation":0,"symbol":"PyTuple_Type"},{"value":4338227072,"symbolLocation":0,"symbol":"usedpools"},{"value":4337427712},{"value":6616541504,"symbolLocation":0,"symbol":"_platform_strchr"},{"value":1600074288},{"value":0},{"value":1},{"value":6136883120},{"value":6136882648},{"value":1},{"value":105553156507264},{"value":3},{"value":105553125119448},{"value":1},{"value":4339160536,"symbolLocation":0,"symbol":"_Py_NoneStruct"},{"value":4346996736}],"flavor":"ARM_THREAD_STATE64","lr":{"value":4343397968},"cpsr":{"value":1610616832},"fp":{"value":6136882592},"sp":{"value":6136882528},"esr":{"value":2449473542,"description":"(Data Abort) byte read Translation fault"},"pc":{"value":4343462008,"matchesCrashFrame":1},"far":{"value":208}},"queue":"com.apple.main-thread","frames":[{"imageOffset":604280,"imageIndex":5},{"imageOffset":540240,"imageIndex":5},{"imageOffset":49540,"imageIndex":5},{"imageOffset":702764,"symbol":"cfunction_call","symbolLocation":60,"imageIndex":1},{"imageOffset":409140,"symbol":"_PyObject_MakeTpCall","symbolLocation":128,"imageIndex":1},{"imageOffset":1294456,"symbol":"_PyEval_EvalFrameDefault","symbolLocation":40660,"imageIndex":1},{"imageOffset":1250912,"symbol":"PyEval_EvalCode","symbolLocation":168,"imageIndex":1},{"imageOffset":1589484,"symbol":"run_eval_code_obj","symbolLocation":84,"imageIndex":1},{"imageOffset":1589328,"symbol":"run_mod","symbolLocation":112,"imageIndex":1},{"imageOffset":1590148,"symbol":"PyRun_InteractiveOneObjectEx","symbolLocation":548,"imageIndex":1},{"imageOffset":1587016,"symbol":"_PyRun_InteractiveLoopObject","symbolLocation":288,"imageIndex":1},{"imageOffset":1585640,"symbol":"_PyRun_AnyFileObject","symbolLocation":76,"imageIndex":1},{"imageOffset":1597704,"symbol":"PyRun_AnyFileExFlags","symbolLocation":84,"imageIndex":1},{"imageOffset":1698780,"symbol":"pymain_run_stdin","symbolLocation":160,"imageIndex":1},{"imageOffset":1696296,"symbol":"Py_RunMain","symbolLocation":348,"imageIndex":1},{"imageOffset":1701060,"symbol":"Py_BytesMain","symbolLocation":40,"imageIndex":1},{"imageOffset":24360,"symbol":"start","symbolLocation":2236,"imageIndex":28}]}],
  "usedImages" : [
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4329996288,
    "CFBundleShortVersionString" : "3.11.5",
    "CFBundleIdentifier" : "org.python.python",
    "size" : 16384,
    "uuid" : "0a04bde3-615c-3696-a606-f5a68271ae34",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/Resources\/Python.app\/Contents\/MacOS\/Python",
    "name" : "Python",
    "CFBundleVersion" : "3.11.5"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4335222784,
    "CFBundleShortVersionString" : "3.11.5, (c) 2001-2023 Python Software Foundation.",
    "CFBundleIdentifier" : "org.python.python",
    "size" : 2736128,
    "uuid" : "9c7fb383-a104-3ffc-9609-fcf3fcb49c5f",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/Python",
    "name" : "Python",
    "CFBundleVersion" : "3.11.5"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4332929024,
    "size" : 32768,
    "uuid" : "58689ef5-193a-3990-9958-4453497030c8",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/readline.cpython-311-darwin.so",
    "name" : "readline.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334059520,
    "size" : 16384,
    "uuid" : "66d8c6b3-fb84-36b2-840b-a13797c6d05c",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_opcode.cpython-311-darwin.so",
    "name" : "_opcode.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334796800,
    "size" : 262144,
    "uuid" : "c85afeb5-eb15-3dce-9fd8-1555770c0b3d",
    "path" : "\/Users\/USER\/*\/_opentime.cpython-311-darwin.so",
    "name" : "_opentime.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4342857728,
    "size" : 1114112,
    "uuid" : "7a3a83b0-28c6-3956-a4fe-61db74c0620d",
    "path" : "\/Users\/USER\/*\/_otio.cpython-311-darwin.so",
    "name" : "_otio.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334125056,
    "size" : 32768,
    "uuid" : "b0a5fab2-03c0-36d3-813f-e5e2ad4e028a",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/zlib.cpython-311-darwin.so",
    "name" : "zlib.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334206976,
    "size" : 16384,
    "uuid" : "a972cae5-ddce-3c55-b967-641c422e81d8",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_bz2.cpython-311-darwin.so",
    "name" : "_bz2.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334370816,
    "size" : 32768,
    "uuid" : "acfad6cd-7d77-3d16-9671-137661fb202f",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_lzma.cpython-311-darwin.so",
    "name" : "_lzma.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4341432320,
    "size" : 131072,
    "uuid" : "7c1e4570-c041-3609-be6b-5baca080a220",
    "path" : "\/opt\/homebrew\/*\/liblzma.5.dylib",
    "name" : "liblzma.5.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334469120,
    "size" : 49152,
    "uuid" : "c0021831-29bc-3ae0-ac24-f36d3e546ce6",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/math.cpython-311-darwin.so",
    "name" : "math.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334272512,
    "size" : 16384,
    "uuid" : "0485697b-5f35-363c-bf21-1ca99882739b",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_bisect.cpython-311-darwin.so",
    "name" : "_bisect.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334567424,
    "size" : 16384,
    "uuid" : "9a40fb5d-035f-3596-bcc6-52ec5b4f06ef",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_random.cpython-311-darwin.so",
    "name" : "_random.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334632960,
    "size" : 16384,
    "uuid" : "d5768942-bc77-3e29-817a-cb14ca2bed2c",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_sha512.cpython-311-darwin.so",
    "name" : "_sha512.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4334698496,
    "size" : 16384,
    "uuid" : "0de32fb1-0c65-3673-a516-8e816433fe23",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_typing.cpython-311-darwin.so",
    "name" : "_typing.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4335124480,
    "size" : 32768,
    "uuid" : "f013a63a-17b6-33f4-b86c-7b3c2b0e84c3",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_csv.cpython-311-darwin.so",
    "name" : "_csv.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4342677504,
    "size" : 32768,
    "uuid" : "72a70cad-76ca-37a9-9d53-82eb43b6a615",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/binascii.cpython-311-darwin.so",
    "name" : "binascii.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4342759424,
    "size" : 32768,
    "uuid" : "fd5ef3bb-abcd-36ad-a5d4-2d9810ecbe69",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_struct.cpython-311-darwin.so",
    "name" : "_struct.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4346347520,
    "size" : 65536,
    "uuid" : "5f090c53-f019-3410-a813-12171a9fec3b",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_socket.cpython-311-darwin.so",
    "name" : "_socket.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4345118720,
    "size" : 32768,
    "uuid" : "299158ec-38c8-3acc-bd1d-07edd1305c2d",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/select.cpython-311-darwin.so",
    "name" : "select.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4345200640,
    "size" : 32768,
    "uuid" : "c9f588aa-b900-3eb1-bc2a-4441025b038e",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/array.cpython-311-darwin.so",
    "name" : "array.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4346593280,
    "size" : 65536,
    "uuid" : "db67441a-0f81-3c26-8b31-c20c3edfe3f8",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_datetime.cpython-311-darwin.so",
    "name" : "_datetime.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4347772928,
    "size" : 32768,
    "uuid" : "0a5eaeee-b18c-3e33-bea3-49b89a59d476",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_hashlib.cpython-311-darwin.so",
    "name" : "_hashlib.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4351377408,
    "size" : 2359296,
    "uuid" : "ee435fd4-fc75-3678-8771-44c5f8fce42d",
    "path" : "\/opt\/homebrew\/*\/libcrypto.3.dylib",
    "name" : "libcrypto.3.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4346462208,
    "size" : 32768,
    "uuid" : "bfb55ded-ac7e-3005-aaad-f9c6caee0732",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_blake2.cpython-311-darwin.so",
    "name" : "_blake2.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4348116992,
    "size" : 114688,
    "uuid" : "29f60baa-c248-37e3-a081-6d39af52d5cc",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_ssl.cpython-311-darwin.so",
    "name" : "_ssl.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4348919808,
    "size" : 360448,
    "uuid" : "10052851-a8b1-309c-ad00-00549cb7a7b9",
    "path" : "\/opt\/homebrew\/*\/libssl.3.dylib",
    "name" : "libssl.3.dylib"
  },
  {
    "source" : "P",
    "arch" : "arm64",
    "base" : 4347887616,
    "size" : 16384,
    "uuid" : "cf36ebee-bf47-3e18-8eca-242681790344",
    "path" : "\/opt\/homebrew\/*\/Python.framework\/Versions\/3.11\/lib\/python3.11\/lib-dynload\/_scproxy.cpython-311-darwin.so",
    "name" : "_scproxy.cpython-311-darwin.so"
  },
  {
    "source" : "P",
    "arch" : "arm64e",
    "base" : 6612819968,
    "size" : 583048,
    "uuid" : "49204446-242b-3d1e-9704-32f8ac99723e",
    "path" : "\/usr\/lib\/dyld",
    "name" : "dyld"
  },
  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }
],
  "sharedCache" : {
  "base" : 6612156416,
  "size" : 3553509376,
  "uuid" : "531c0369-32b5-3499-ad7a-31d86a6e6b93"
},
  "vmSummary" : "ReadOnly portion of Libraries: Total=922.8M resident=0K(0%) swapped_out_or_unallocated=922.8M(100%)\nWritable regions: Total=1.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.1G(100%)\n\n                                VIRTUAL   REGION \nREGION TYPE                        SIZE    COUNT (non-coalesced) \n===========                     =======  ======= \nKernel Alloc Once                   32K        1 \nMALLOC                           215.2M       26 \nMALLOC guard page                   96K        5 \nMALLOC_MEDIUM (reserved)         480.0M        4         reserved VM address space (unallocated)\nMALLOC_NANO (reserved)           384.0M        1         reserved VM address space (unallocated)\nSTACK GUARD                         16K        1 \nStack                             16.0M        1 \nVM_ALLOCATE                       8208K        9 \n__AUTH                             309K       60 \n__AUTH_CONST                      3716K      144 \n__DATA                            3326K      166 \n__DATA_CONST                      5123K      173 \n__DATA_DIRTY                       361K       58 \n__LINKEDIT                       804.4M       29 \n__OBJC_RO                         66.4M        1 \n__OBJC_RW                         2012K        1 \n__TEXT                           118.4M      180 \ndyld private memory                272K        2 \nshared memory                       32K        2 \n===========                     =======  ======= \nTOTAL                              2.1G      864 \nTOTAL, minus reserved VM space     1.2G      864 \n",
  "legacyInfo" : {
  "threadTriggered" : {
    "queue" : "com.apple.main-thread"
  }
},
  "logWritingSignature" : "fd08294afa547c921b2e42c4817720071af98b13",
  "trialInfo" : {
  "rollouts" : [
    {
      "rolloutId" : "5fb4245a1bbfe8005e33a1e1",
      "factorPackIds" : {

      },
      "deploymentId" : 240000021
    },
    {
      "rolloutId" : "60186475825c62000ccf5450",
      "factorPackIds" : {

      },
      "deploymentId" : 240000068
    }
  ],
  "experiments" : [

  ]
}
}

Model: Mac14,6, BootROM 10151.41.12, proc 12:8:4 processors, 64 GB, SMC 
Graphics: Apple M2 Max, Apple M2 Max, Built-In
Display: BenQ PD2700U, 6016 x 3384, Main, MirrorOff, Online
Display: Color LCD, 3456 x 2234 Retina, MirrorOff, Online
Memory Module: LPDDR5, Hynix
AirPort: spairport_wireless_card_type_wifi (0x14E4, 0x4388), wl0: Jun 11 2023 05:20:59 version 23.20.95.0.40.50.92 FWID 01-ec505a98
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
PCI Card: pci1b73,1100, USB eXtensible Host Controller, Thunderbolt@6,0,0
PCI Card: pci1b21,1242, USB eXtensible Host Controller, Thunderbolt@4,0,0
PCI Card: ethernet, Ethernet Controller, Thunderbolt@3,0,0
PCI Card: pci1b73,1100, USB eXtensible Host Controller, Thunderbolt@5,0,0
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB31Bus
USB Device: USB30Bus
USB Device: CalDigit Thunderbolt 3 Audio
USB Device: USB30Bus
USB Device: Card Reader
USB Device: USB3.1 Hub
USB Device: USB2.1 Hub
USB Device: hub_device
USB Device: CTRL Keyboard
USB Device: Razer DeathAdder V3 Pro
USB Device: Razer DeathAdder V3 Pro
USB Device: Logitech Webcam C930e
USB Device: USB31Bus
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Device: TS3 Plus, CalDigit, Inc., 1, 35.1
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
@reinecke reinecke added the bug A problem, flaw, or broken functionality. label Nov 16, 2023
@JeanChristopheMorinPerso
Copy link
Member

Composition and SerializableCollection are handled slightly differently:

_add_mutable_sequence_methods(_otio.Composition, side_effecting_insertions=True)
_add_mutable_sequence_methods(_otio.SerializableCollection)

Here is the backtrace with OTIO built in debug mode:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   _otio.cpython-311-darwin.so   	       0x1062db050 opentimelineio::v1_0::Composable::parent() const + 12
1   _otio.cpython-311-darwin.so   	       0x10634b698 opentimelineio::v1_0::Composition::insert_child(int, opentimelineio::v1_0::Composable*, opentimelineio::v1_0::ErrorStatus*) + 44
2   _otio.cpython-311-darwin.so   	       0x10630b794 define_items_and_compositions(pybind11::module_)::$_67::operator()(opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*) const + 140
3   _otio.cpython-311-darwin.so   	       0x10630b6fc void pybind11::detail::argument_loader<opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*>::call_impl<void, define_items_and_compositions(pybind11::module_)::$_67&, 0ul, 1ul, 2ul, pybind11::detail::void_type>(define_items_and_compositions(pybind11::module_)::$_67&, std::__1::integer_sequence<unsigned long, 0ul, 1ul, 2ul>, pybind11::detail::void_type&&) && + 112
4   _otio.cpython-311-darwin.so   	       0x10630b680 std::__1::enable_if<std::is_void<void>::value, pybind11::detail::void_type>::type pybind11::detail::argument_loader<opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*>::call<void, pybind11::detail::void_type, define_items_and_compositions(pybind11::module_)::$_67&>(define_items_and_compositions(pybind11::module_)::$_67&) && + 36
5   _otio.cpython-311-darwin.so   	       0x10630b618 void pybind11::cpp_function::initialize<define_items_and_compositions(pybind11::module_)::$_67, void, opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(define_items_and_compositions(pybind11::module_)::$_67&&, void (*)(opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::'lambda'(pybind11::detail::function_call&)::operator()(pybind11::detail::function_call&) const + 132
6   _otio.cpython-311-darwin.so   	       0x10630b578 void pybind11::cpp_function::initialize<define_items_and_compositions(pybind11::module_)::$_67, void, opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*, pybind11::name, pybind11::is_method, pybind11::sibling, pybind11::arg, pybind11::arg>(define_items_and_compositions(pybind11::module_)::$_67&&, void (*)(opentimelineio::v1_0::Composition*, int, opentimelineio::v1_0::Composable*), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&, pybind11::arg const&, pybind11::arg const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) + 28
7   _otio.cpython-311-darwin.so   	       0x1061b8354 pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 4020
8   Python                        	       0x1048fef4c cfunction_call + 60
9   Python                        	       0x1048b6cd0 _PyObject_MakeTpCall + 128
10  Python                        	       0x10498fe34 _PyEval_EvalFrameDefault + 40596
11  Python                        	       0x104985444 PyEval_EvalCode + 168
12  Python                        	       0x1049daa18 run_eval_code_obj + 84
13  Python                        	       0x1049da97c run_mod + 112
14  Python                        	       0x1049dcdbc PyRun_StringFlags + 112
15  Python                        	       0x1049dcd04 PyRun_SimpleStringFlags + 64
16  Python                        	       0x1049f54e0 pymain_run_command + 144
17  Python                        	       0x1049f4fb4 Py_RunMain + 228
18  Python                        	       0x1049f62c8 Py_BytesMain + 40
19  dyld                          	       0x18af1bf28 start + 2236

@JeanChristopheMorinPerso
Copy link
Member

JeanChristopheMorinPerso commented Nov 17, 2023

A fix could simply be something like

diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
index c52ab4c..37c5957 100644
--- a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
+++ b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
@@ -521,9 +521,9 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u
                 index = adjusted_vector_index(index, c->children());
                 c->remove_child(index, ErrorStatusHandler());
             }, "index"_a)
-        .def("__internal_insert", [](Composition* c, int index, Composable* composable) {
+        .def("__internal_insert", [](Composition* c, int index, Composable &composable) {
                 index = adjusted_vector_index(index, c->children());
-                c->insert_child(index, composable, ErrorStatusHandler());
+                c->insert_child(index, &composable, ErrorStatusHandler());
             }, "index"_a, "item"_a)
         .def("__contains__", &Composition::has_child, "composable"_a)
         .def("__len__", [](Composition* c) {

which gives us what you want:

(.venv) jcmorin$ python -c 'import opentimelineio as otio; track = otio.schema.Track(); track.append(None)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "<frozen _collections_abc>", line 1078, in append
  File "/private/tmp/asd/.venv/lib/python3.11/site-packages/opentimelineio/core/_core_utils.py", line 359, in insert
    self.__internal_insert(
TypeError: __internal_insert(): incompatible function arguments. The following argument types are supported:
    1. (self: opentimelineio._otio.Composition, index: int, item: opentimelineio._otio.Composable) -> None

Invoked with: otio.schema.Track(name='', children=[], source_range=None, metadata={}), 0, None

@JeanChristopheMorinPerso
Copy link
Member

JeanChristopheMorinPerso commented Nov 17, 2023

I personally always wondered why OTIO uses pointer parameters for these things instead of reference parameters in the python bindings.

@reinecke reinecke added the good first issue If you're looking for a way to contribute, but not sure where to start. This is a good first issue. label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A problem, flaw, or broken functionality. good first issue If you're looking for a way to contribute, but not sure where to start. This is a good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants