davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
199 stars 58 forks source link

unhandled exception in cpychecker #86

Open davidmalcolm opened 7 years ago

davidmalcolm commented 7 years ago

Consider this source: {{{

include

extern PyObject *gdb_module; extern PyTypeObject eventregistry_object_type;

void gdbpy_initialize_eventregistry (void) { if (PyType_Ready (&eventregistry_object_type) < 0) return;

Py_INCREF (&eventregistry_object_type); PyModule_AddObject (gdb_module, "EventRegistry", (PyObject *) &eventregistry_object_type); } }}}

While mildly bogus (no error checking), it should not provoke an unhandled exception in the checker:

{{{ typeready.c: In function ‘gdbpy_initialize_eventregistry’: typeready.c:13:22: error: Unhandled Python exception raised calling 'execute' method Traceback (most recent call last): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/init.py", line 79, in execute self._check_refcounts(fun) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/init.py", line 85, in _check_refcounts dump_json=self.dump_json) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py", line 4361, in check_refcounts maxtrans) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py", line 4216, in impl_check_refcounts limits=limits) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3073, in iter_traces depth + 1): File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 3037, in iter_traces transitions = curstate.get_transitions() File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 2089, in get_transitions return self._get_transitions_for_stmt(stmt) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 2105, in _get_transitions_for_stmt return self._get_transitions_for_GimpleCall(stmt) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/absinterp.py", line 2276, in _get_transitions_for_GimpleCall return meth(stmt, *args) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py", line 2546, in impl_PyModule_AddObject s_success.cpython.steal_reference(v_value, stmt.loc) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py", line 744, in steal_reference _steal_ref) File "/home/tromey/Space/Trunk/gcc-python-plugin/libcpychecker/refcounts.py", line 554, in change_refcount check_isinstance(oldvalue, RefcountValue) File "/home/tromey/Space/Trunk/gcc-python-plugin/gccutils/init.py", line 637, in check_isinstance raise TypeError('%s / %r is not an instance of %s' % (obj, obj, types)) TypeError: (long int)val [-0x7fffffffffffffff <= val <= 0x7fffffffffffffff] from typeready.c:12 / WithinRange(gcctype='long int', loc=gcc.Location(file='typeready.c', line=12), minvalue=-0x7fffffffffffffff, maxvalue=0x7fffffffffffffff) is not an instance of <class 'libcpychecker.refcounts.RefcountValue'> }}}

davidmalcolm commented 7 years ago

Imported from trac issue 46. Created by tromey on 2013-04-17T14:16:29, last modified: 2013-04-18T11:18:00

davidmalcolm commented 7 years ago

Trac comment by tromey on 2013-04-18 11:18:00:

If I comment out the Py_INCREF line, the exception goes away.