Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • P PyAV
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 37
    • Issues 37
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 26
    • Merge requests 26
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • PyAV
  • PyAV
  • Issues
  • #23
Closed
Open
Issue created Nov 01, 2013 by Mike Boers@mikeboers

Exception at shutdown

I spent a quite a few hours hitting my head on this one.

For some reason, calling lib.avformat_close_input (in av.context.ContextProxy.__dealloc__) sets up conditions such that a weakrefset somehow related to the UserDict that is os.environ calls a None object during shutdown:

Exception TypeError: "'NoneType' object is not callable" in <function _remove at 0x102ac6410> ignored

However, calling os.environ.__iter__() (and not os.environ.data.__iter__() "fixes" this. Even stranger, os.environ.__iter__() simply calls os.environ.data.__iter__().

I have established that much via debugging CPython with gdb and as much introspection as I can muster from there, and via this fix

I don't even...


If you feel like debugging this some more:

  1. manually compile CPython with no optimization (I edited the Makefile to remove the -O2 flags... shaddup);
  2. install it and Cython;
  3. gdb python and break PyErr_WriteUnraisable;
  4. run -m examples.encode path/to/movie;

The stack looks roughly like:

#0  PyErr_WriteUnraisable (obj=0x1004c6488) at errors.c:649
#1  0x00000001000bb879 in handle_callback (ref=0x100456db8, callback=0x1004c6488) at weakrefobject.c:895
#2  0x00000001000bbc6d in PyObject_ClearWeakRefs (object=0x10046ace8) at weakrefobject.c:976
#3  0x0000000100023707 in class_dealloc (op=0x10046ace8) at classobject.c:193
#4  0x000000010009d34b in tupledealloc (op=0x100467a90) at tupleobject.c:222
#5  0x0000000100023748 in class_dealloc (op=0x10046abb0) at classobject.c:194
#6  0x0000000100025317 in instance_dealloc (inst=0x10046d2d8) at classobject.c:680
#7  0x000000010006c323 in insertdict_by_entry (mp=0x100321910, key=0x1004421e0, hash=-5347984860299468300, ep=0x10084b6e0, value=0x1001fb470) at dictobject.c:519
#8  0x000000010006c530 in insertdict (mp=0x100321910, key=0x1004421e0, hash=-5347984860299468300, value=0x1001fb470) at dictobject.c:556
#9  0x000000010006ce49 in dict_set_item_by_hash_or_entry (op=0x100321910, key=0x1004421e0, hash=-5347984860299468300, ep=0x0, value=0x1001fb470) at dictobject.c:765
#10 0x000000010006d03f in PyDict_SetItem (op=0x100321910, key=0x1004421e0, value=0x1001fb470) at dictobject.c:818
#11 0x0000000100077056 in _PyModule_Clear (m=0x10044f168) at moduleobject.c:138
#12 0x000000010013bfdc in PyImport_Cleanup () at import.c:526
#13 0x00000001001510a9 in Py_Finalize () at pythonrun.c:454
#14 0x000000010017481f in Py_Main (argc=4, argv=0x7fff5fbff650) at main.c:665
#15 0x00000001000012d0 in main (argc=4, argv=0x7fff5fbff650) at python.c:23

It seems to be dealing with weakrefs on the _Environ that is os.environ.

Assignee
Assign to
Time tracking