Skip to content

Instantly share code, notes, and snippets.

@devdanzin
Created March 18, 2026 10:06
Show Gist options
  • Select an option

  • Save devdanzin/a29b3efc400d564b195f09dc94fb6b1e to your computer and use it in GitHub Desktop.

Select an option

Save devdanzin/a29b3efc400d564b195f09dc94fb6b1e to your computer and use it in GitHub Desktop.
instrumentation.c: PyLong leaked per C API monitoring call

instrumentation.c: PyLong leaked per C API monitoring call

Summary

capi_call_instrumentation (line 2609) creates offset_obj = PyLong_FromLong(offset) stored in args[2] but never calls Py_DECREF. Affects ~16 _PyMonitoring_Fire*Event C API functions. Unbounded memory growth in long-running apps using C monitoring.

Fix

Add Py_DECREF(args[2]) before return (for non-LINE events).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment