davidmalcolm / gcc-python-plugin

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

CPyChecker crash #91

Closed davidmalcolm closed 7 years ago

davidmalcolm commented 7 years ago

Fedora 18, Python 2.7.3.

Steps:

get gcc-python-plugin-0.12

build with Python 2.7.3.

clone https://github.com/mongodb/mongo-python-driver/ from master, we're currently at commit hash 80b8cfef

cd mongo-python-driver

CC=~/gcc-python-plugin-0.12/gcc-with-cpychecker python setup.py build

Expected: CPyChecker completes without AssertionErrors and tracebacks, writes HTML output.

Actual: CPyChecker writes a bunch of AssertionErrors and tracebacks, crashes.

Output attached.

davidmalcolm commented 7 years ago

Imported from trac issue 51. Created by emptysquare on 2013-06-24T21:43:47, last modified: 2013-06-25T14:24:29

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2013-06-25 11:25:45:

Thanks for reporting this.

Notes to self: looking at the attached log, all errors are of the form: {{{ File "/home/vagrant/gcc-python-plugin-0.12-python2/libcpychecker/absinterp.py", line 1158, in next_loc 866 assert len(self.bb.succs) == 1 }}} i.e. it thinks that the basic block should have a single successor, but for some reason there are multiple successors (or perhaps none?)

I've seen this kind of thing before when the compiler has C++ exception-handling enabled, but given that this is C code I suspect that something else is going on.

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2013-06-25 11:34:44:

Aha: I see "-fexceptions" in the build log: is that something that mongo-python-driver is adding, or did this come drom distutils?

Does it work if you remove "-fexceptions" from the arguments to GCC?

(For reference, what exact version of gcc are you using?)

Thanks

davidmalcolm commented 7 years ago

Trac comment by emptysquare on 2013-06-25 12:21:47:

$ gcc --version

gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8)

I'm going to see how to remove the -fexceptions flag. It comes from setuptools 0.6 / distutils rather than being configured explicitly in our setup.py.

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2013-06-25 14:00:31:

Should be fixed as of https://git.fedorahosted.org/cgit/gcc-python-plugin.git/commit/?id=6d8b81c0fab8c3bf9d154768f5f3d0e248b341ac

davidmalcolm commented 7 years ago

Trac comment by emptysquare on 2013-06-25 14:16:58:

Great thanks! I'll try this out.

Note that the default compiler flags come from the way Python itself was built:

{{{

import sysconfig sysconfig.get_config_vars()['CFLAGS'] '-fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv'}}}

davidmalcolm commented 7 years ago

Trac comment by emptysquare on 2013-06-25 14:18:07:

Incidentally, is this a duplicate of #43?

davidmalcolm commented 7 years ago

Trac comment by dmalcolm on 2013-06-25 14:24:29:

Replying to [comment:6 emptysquare]:

Incidentally, is this a duplicate of #43? Yes. Perhaps we should keep #43 open, given that so far all we have is a band-aid, rather than properly analyzing exception-handling.