Consider this plugin:
class Whatever:
def doit(self, optpass, fun, *args, **kwargs):
print "hi bob"
def main(**kwargs):
w = Whatever()
gcc.register_callback(gcc.PLUGIN_PASS_EXECUTION, w.doit)
When I try to run this (invoking main...), I get an ICE:
*** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.
Event | Plugins
PLUGIN_FINISH | python
PLUGIN_PASS_EXECUTION | python
../../archer/gdb/python/py-type.c: In function ‘gdbpy_initialize_types’:
../../archer/gdb/python/py-type.c:1378:1: internal compiler error: Segmentation fault
The bug is a missing incref in gcc-python-closure.c. Patch appended.
Tom
diff --git a/gcc-python-closure.c b/gcc-python-closure.c
index 5c9b8ae..f238914 100644
--- a/gcc-python-closure.c
+++ b/gcc-python-closure.c
@@ -39,6 +39,7 @@ gcc_python_closure_new_generic(PyObject *callback, PyObject *extraargs, PyObject
}
closure->callback = callback;
+ Py_INCREF(callback);
// FIXME: we may want to pass in the event enum as well as the user-supplied extraargs