public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc-python-plugin finds its first bug in itself
@ 2011-08-05 17:08 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2011-08-05 17:08 UTC (permalink / raw)
  To: gcc, gcc-python-plugin

gcc-python-plugin [1] now provides a gcc-with-cpychecker harness that
runs gcc with an additional pass that checks CPython API calls
(internally, it's using the gcc python plugin to run a python script
that does the work).

I tried rebuilding the plugin using
  make CC=../other-build/gcc-with-cpychecker
and it found a genuine bug in itself: within this code:

   350	PyObject *
   351	gcc_Pass_get_by_name(PyObject *cls, PyObject *args, PyObject *kwargs)
   352	{
   353	    const char *name;
   354	    char *keywords[] = {"name",
   355	                        NULL};
   356	    struct opt_pass *result;
   357	
   358	    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
   359	                                     "s|get_by_name", keywords,
   360	                                     &name)) {
   361	        return NULL;
   362	    }
   363  [...snip...]

it found this problem:

gcc-python-pass.c: In function ‘gcc_Pass_get_by_name’:
gcc-python-pass.c:358:37: error: unknown format char in "s|get_by_name": 'g' [-fpermissive]

It turned out that I'd typo-ed the format code: I was erroneously using
"|" (signifying that optional args follow), when I meant to use
":" (signifying that the rest of the string is the name of the function,
for use in error messages) [2].

Fixed in git; there are a few false positives, which I'm working on
fixing now.

I'm in two minds about whether this (minor) milestone is one I should
mention in public, but I guess it's proof that having a static checker
for this kind of mistake is worthwhile :)

Dave

[1] https://fedorahosted.org/gcc-python-plugin/

[2] fwiw, the API that it's checking is here:
http://docs.python.org/c-api/arg.html

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-05 17:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-05 17:08 gcc-python-plugin finds its first bug in itself David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).