davidmalcolm / gcc-python-plugin

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

Many errors cloud output GCC 4.8.3 / RHEL6 #100

Open davidmalcolm opened 7 years ago

davidmalcolm commented 7 years ago

GCC 4.8.3 + Python 2.7.2; gcc-python-plugin compiled from source on RHEL6

Code @ https://github.com/ged-lab/khmer/tree/ad07a21a84039b40beb3db515e321a251b9460c3 Invocation: CC='gcc-with-cpychecker --maxtrans=512' python setup.py build_ext

Many failure motifs:

1) TypeErrors: ... is not an instance of <type 'gcc.PointerType'> (34 times) 2) AttributeError: 'NoneType' object has no attribute 'file' (15 times) 3) AttributeError: 'gcc.ObjTypeRef' object has no attribute 'operand'(31 times)

Ultimately the attempt fails with "error: command 'gcc-with-cpychecker' failed with exit status 1"

gcc-plugin-python tests that fail: tests/cpychecker/refcounts/PyDict_GetItem/correct tests/cpychecker/refcounts/PyDict_GetItemString/correct tests/cpychecker/refcounts/PyErr_Format/correct tests/cpychecker/refcounts/PyErr_PrintEx tests/cpychecker/refcounts/PyErr_SetFromErrno/correct tests/cpychecker/refcounts/PyErr_SetNone/correct tests/cpychecker/refcounts/PyErr_SetObject/correct tests/cpychecker/refcounts/PyErr_SetString/correct tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking tests/cpychecker/refcounts/attributes/sets-exception/correct-marking

The first 10 fail as the Python include path is nonstandard (/opt/software/Python/2.7.2--GCC-4.4.5/include/python2.7).

Here's the dump of the last test:

tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic: FAIL [148/9842]

returncode: 0 compiling: /opt/software/GCC/4.8.3/bin/gcc -c -fno-diagnostics-show-caret -ftrack-macro-expansion=0 -o tests/cpychecker/refcounts/PyUnicod e_AsUTF8String/basic/output.o -fplugin=/mnt/home/mcrusoe/src/gcc-python-plugin/python.so -fplugin-arg-python-script=tests/cpychecker/refcoun ts/PyUnicode_AsUTF8String/basic/script.py -fsigned-char -I/opt/software/Python/2.7.2--GCC-4.4.5/include/python2.7 tests/cpychecker/refcounts /PyUnicode_AsUTF8String/basic/input.c Stdout: Trace 0: Transitions: 'when PyUnicodeUCS2_AsUTF8String() succeeds' 'returning' Return value: repr(): PointerToRegion(gcctype='struct PyObject ', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/in put.c', line=29), region=RegionOnHeap('new ref from (unknown) PyUnicodeUCS2_AsUTF8String', gcc.Location(file='tests/cpychecker/refcounts/PyU nicode_AsUTF8String/basic/input.c', line=29))) str(): (struct PyObject )&RegionOnHeap('new ref from (unknown) PyUnicodeUCS2_AsUTF8String', gcc.Location(file='tests/cpychecker/refco unts/PyUnicode_AsUTF8String/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:29 r->ob_refcnt: refs: 1 owned r->ob_type: PointerToRegion(gcctype='struct PyTypeObject ', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/ basic/input.c', line=29), region=Region('PyTypeObject for new ref from (unknown) PyUnicodeUCS2_AsUTF8String')) region for gcc.ParmDecl('unicode') on stack: repr(): RegionOnStack("region for gcc.ParmDecl('unicode')") str(): region for gcc.ParmDecl('unicode') on stack r->ob_refcnt: refs: 0 owned, 1 borrowed r->ob_type: PointerToRegion(gcctype='struct PyTypeObject ', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/ basic/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('unicode')")) Exception: (struct PyObject )0 from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:28 Trace 1: [118/9842] Transitions: 'when PyUnicodeUCS2_AsUTF8String() fails' 'returning' Return value: repr(): ConcreteValue(gcctype='struct PyObject ', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/inpu t.c', line=29), value=0) str(): (struct PyObject )0 from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:29 region for gcc.ParmDecl('unicode') on stack: repr(): RegionOnStack("region for gcc.ParmDecl('unicode')") str(): region for gcc.ParmDecl('unicode') on stack r->ob_refcnt: refs: 0 owned, 1 borrowed r->ob_type: PointerToRegion(gcctype='struct PyTypeObject ', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/ basic/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('unicode')")) Exception: (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/inp ut.c:29 Stderr: --- Expected stdout (after cleaning) +++ Actual stdout (after cleaning) @@ -1,12 +1,12 @@ Trace 0: Transitions:

Representative TypeError:

In file included from khmer/_khmermodule.cc:20:0: lib/hashtable.hh: In destructor ‘khmer::Hashtable::~Hashtable()’: lib/hashtable.hh:238:53: error: Unhandled Python exception raised calling 'execute' method delete _thread_id_maps[ thread_pool_id ]; ^ Traceback (most recent call last): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/init.py", line 79, in execute self._check_refcounts(fun) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/init.py", line 85, in _check_refcounts dump_json=self.dump_json) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/refcounts.py", line 4393, in check_refcounts maxtrans) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/refcounts.py", line 4248, in impl_check_refcounts limits=limits) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 3033, in iter_traces depth + 1): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 2997, in iter_traces transitions = curstate.get_transitions() File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 2049, in get_transitions return self._get_transitions_for_stmt(stmt) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 2076, in _get_transitions_for_stmt return self._get_transitions_for_GimpleAssign(stmt) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 2581, in _get_transitions_for_GimpleAssign value = self.eval_rhs(stmt) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 2544, in eval_rhs return self.eval_rvalue(rhs[0], stmt.loc) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 1549, in eval_rvalue self.raise_split_value(opvalue) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/absinterp.py", line 2020, in raise_split_value check_isinstance(ptr_rvalue.gcctype, gcc.PointerType) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/gccutils/init.py", line 637, in check_isinstance raise TypeError('%s / %r is not an instance of %s' % (obj, obj, types)) TypeError: struct ThreadIDMap * & / <gcc.ReferenceType object at 0x1d6ea30> is not an instance of <type 'gcc.PointerType'>

A reporting error:

/opt/software/GCC/4.8.3/include/c++/4.8.3/bits/stl_tree.h: In member function ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::allocator_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::get_allocator() const [with _Key = unsigned int; _Val = std::pair<const unsigned int, khmer::ThreadIDMap>; _KeyOfValue = std::_Select1st<std::pair<const unsigned int, khmer::ThreadIDMap> >; _Compare = std::less; _Alloc = std::allocator<std::pair<const unsigned int, khmer::ThreadIDMap> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::allocator_type = std::allocator<std::pair<const unsigned int, khmer::ThreadIDMap> >]’: /opt/software/GCC/4.8.3/include/c++/4.8.3/bits/stl_tree.h:365:54: error: Unhandled Python exception raised calling 'execute' method { return allocator_type(_M_get_Node_allocator()); } ^ Traceback (most recent call last): File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/init.py", line 79, in execute self._check_refcounts(fun) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/init.py", line 85, in _check_refcounts dump_json=self.dump_json) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/refcounts.py", line 4413, in check_refcounts rep.dump_html(fun, filename) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/diagnostics.py", line 158, in dump_html html = self.to_html(fun) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/diagnostics.py", line 153, in to_html html += r.make_report(report) File "/opt/software/gcc-python-plugin/0.13--GCC-4.8.3/libcpychecker/visualizations.py", line 296, in make_report result += ' File: %s\n' % self.fun.start.file AttributeError: 'NoneType' object has no attribute 'file'

davidmalcolm commented 7 years ago

Imported from trac issue 59. Created by biocrusoe on 2014-12-08T17:41:42, last modified: 2014-12-08T17:41:42