Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
List overview
Download
gcc-python-plugin-commits
September 2011
----- 2024 -----
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
gcc-python-plugin-commits@lists.stg.fedorahosted.org
1 participants
71 discussions
Start a n
N
ew thread
[gcc-python-plugin] cpychecker: implement PyDict_SetItemString
by David Hugh Malcolm
01 Sep '11
01 Sep '11
commit efc20c87cc58854f87e5fbf68c036f9997727cc4 Author: David Malcolm <dmalcolm(a)redhat.com> Date: Thu Sep 1 15:45:19 2011 -0400 cpychecker: implement PyDict_SetItemString libcpychecker/refcounts.py | 59 ++++- .../refcounts/PyDict_SetItemString/correct/input.c | 69 +++++ .../PyDict_SetItemString/correct/script.py | 22 ++ .../PyDict_SetItemString/correct/stdout.txt | 312 ++++++++++++++++++++ .../PyDict_SetItemString/incorrect/input.c | 70 +++++ .../PyDict_SetItemString/incorrect/script.py | 22 ++ .../PyDict_SetItemString/incorrect/stderr.txt | 18 ++ .../PyDict_SetItemString/incorrect/stdout.txt | 277 +++++++++++++++++ 8 files changed, 846 insertions(+), 3 deletions(-) --- diff --git a/libcpychecker/refcounts.py b/libcpychecker/refcounts.py index d8de452..1f1a022 100644 --- a/libcpychecker/refcounts.py +++ b/libcpychecker/refcounts.py @@ -290,20 +290,50 @@ class MyState(State): raise NotImplementedError("Don't know how to cope with %r (%s) at %s" % (stmt, stmt, stmt.loc)) - def add_ref(self, pyobjectptr, loc): + def change_refcount(self, pyobjectptr, loc, fn): + """ + Manipulate pyobjectptr's ob_refcnt. + + fn is a function taking a RefcountValue instance, returning another one + """ assert isinstance(pyobjectptr, AbstractValue) assert isinstance(pyobjectptr, PointerToRegion) ob_refcnt = self.make_field_region(pyobjectptr.region, 'ob_refcnt') assert isinstance(ob_refcnt, Region) oldvalue = self.get_store(ob_refcnt, None, loc) # FIXME: gcctype assert isinstance(oldvalue, AbstractValue) - log('oldvalue: %r' % oldvalue) + log('oldvalue: %r', oldvalue) #if isinstance(oldvalue, UnknownValue): # self.raise_split_value(oldvalue, loc) assert isinstance(oldvalue, RefcountValue) - newvalue = RefcountValue(oldvalue.relvalue + 1, oldvalue.min_external) + newvalue = fn(oldvalue) + log('newvalue: %r', newvalue) self.value_for_region[ob_refcnt] = newvalue + def add_ref(self, pyobjectptr, loc): + """ + Add a "visible" reference to pyobjectptr's ob_refcnt i.e. a reference + being held by a PyObject* that we are directly tracking. + """ + def _incref_internal(oldvalue): + return RefcountValue(oldvalue.relvalue + 1, + oldvalue.min_external) + self.change_refcount(pyobjectptr, + loc, + _incref_internal) + + def add_external_ref(self, pyobjectptr, loc): + """ + Add an "external" reference to pyobjectptr's ob_refcnt i.e. a reference + being held by a PyObject* that we're not directly tracking. + """ + def _incref_external(oldvalue): + return RefcountValue(oldvalue.relvalue, + oldvalue.min_external + 1) + self.change_refcount(pyobjectptr, + loc, + _incref_external) + def set_exception(self, exc_name): """ Given the name of a (PyObject*) global for an exception class, such as @@ -588,6 +618,29 @@ class MyState(State): t_notfound] #t_memoryexc] + def impl_PyDict_SetItemString(self, stmt): + # Declared in dictobject.h: + # PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); + # Defined in dictobject.c + # + # API docs: + #
http://docs.python.org/c-api/dict.html#PyDict_SetItemString
+ # Can return -1, setting MemoryError + # Otherwise returns 0, and adds a ref on the value + v_dp, v_key, v_item = self.eval_stmt_args(stmt) + + s_success = self.mkstate_concrete_return_of(stmt, 0) + # the dictionary now owns a new ref on "item". We won't model the + # insides of the dictionary type. Instead, treat it as a new + # external reference: + s_success.add_external_ref(v_item, stmt.loc) + + s_failure = self.mkstate_concrete_return_of(stmt, -1) + s_failure.set_exception('PyExc_MemoryError') + + return self.make_transitions_for_fncall(stmt, s_success, s_failure) + + ######################################################################## # PyErr_* ######################################################################## diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c b/tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c new file mode 100644 index 0000000..6ac0f1c --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c @@ -0,0 +1,69 @@ +/* + Copyright 2011 David Malcolm <dmalcolm(a)redhat.com> + Copyright 2011 Red Hat, Inc. + + This is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + <
http://www.gnu.org/licenses/
>. +*/ + +#include <Python.h> + +/* + Test of correct reference-handling in a call to PyDict_SetItemString +*/ + +PyObject * +test(PyObject *self, PyObject *args) +{ + PyObject *dict = NULL; + PyObject *value = NULL; + + dict = PyDict_New(); + if (!dict) { + goto error; + } + + value = PyLong_FromLong(1000); + if (!value) { + goto error; + } + + if (-1 == PyDict_SetItemString(dict, "key", value)) { + goto error; + } + /* + The successful call added a ref on "value", owned by the dictionary. + We must now drop our reference on in: + */ + Py_DECREF(value); + + return dict; + + error: + Py_XDECREF(dict); + Py_XDECREF(value); + return NULL; +} +static PyMethodDef test_methods[] = { + {"test_method", test, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +/* + PEP-7 +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/correct/script.py b/tests/cpychecker/refcounts/PyDict_SetItemString/correct/script.py new file mode 100644 index 0000000..fdd5ba3 --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/correct/script.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2011 David Malcolm <dmalcolm(a)redhat.com> +# Copyright 2011 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <
http://www.gnu.org/licenses/
>. + +from libcpychecker import main +main(verify_refcounting=True, + dump_traces=True, + show_traces=False) diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/correct/stdout.txt b/tests/cpychecker/refcounts/PyDict_SetItemString/correct/stdout.txt new file mode 100644 index 0000000..7b5c3bd --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/correct/stdout.txt @@ -0,0 +1,312 @@ +Trace 0: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() succeeds' + 'taking False path' + 'taking True path' + 'returning' + Return value: + repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))) + str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: refs: 1 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37 + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type'))) + Exception: + (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:28 + +Trace 1: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() succeeds' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37' + 'returning' + Return value: + repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))) + str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: refs: 1 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37 + r->ob_refcnt: None + r->ob_type: None + Exception: + (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:28 + +Trace 2: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking True path' + 'taking False path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type'))) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 3: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37 + r->ob_refcnt: None + r->ob_type: None + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 4: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32' + 'taking False path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: None + r->ob_type: None + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type'))) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 5: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: None + r->ob_type: None + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37 + r->ob_refcnt: None + r->ob_type: None + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 6: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() fails' + 'taking True path' + 'taking False path' + 'taking True path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 7: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() fails' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32 + r->ob_refcnt: None + r->ob_type: None + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 8: + Transitions: + 'PyDict_New() fails' + 'taking True path' + 'taking True path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c new file mode 100644 index 0000000..cdd4666 --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c @@ -0,0 +1,70 @@ +/* + Copyright 2011 David Malcolm <dmalcolm(a)redhat.com> + Copyright 2011 Red Hat, Inc. + + This is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see + <
http://www.gnu.org/licenses/
>. +*/ + +#include <Python.h> + +/* + Test of incorrect reference-handling in a call to PyDict_SetItemString +*/ + +PyObject * +test(PyObject *self, PyObject *args) +{ + PyObject *dict = NULL; + PyObject *value = NULL; + + dict = PyDict_New(); + if (!dict) { + goto error; + } + + value = PyLong_FromLong(1000); + if (!value) { + goto error; + } + + if (-1 == PyDict_SetItemString(dict, "key", value)) { + goto error; + } + /* + The successful call added a ref on "value", owned by the dictionary. + + However, we still hold another reference on "value", and this code + erroneously fails to call Py_DECREF on it, which will be a leak. + */ + + return dict; + + error: + Py_XDECREF(dict); + Py_XDECREF(value); + return NULL; +} +static PyMethodDef test_methods[] = { + {"test_method", test, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +/* + PEP-7 +Local variables: +c-basic-offset: 4 +indent-tabs-mode: nil +End: +*/ diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/script.py b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/script.py new file mode 100644 index 0000000..fdd5ba3 --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/script.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Copyright 2011 David Malcolm <dmalcolm(a)redhat.com> +# Copyright 2011 Red Hat, Inc. +# +# This is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see +# <
http://www.gnu.org/licenses/
>. + +from libcpychecker import main +main(verify_refcounting=True, + dump_traces=True, + show_traces=False) diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stderr.txt b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stderr.txt new file mode 100644 index 0000000..01ba16c --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stderr.txt @@ -0,0 +1,18 @@ +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c: In function 'test': +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:58:1: error: ob_refcnt of PyLongObject is 1 too high +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:58:1: note: was expecting final ob_refcnt to be N + 0 (for some unknown N) +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:58:1: note: but final ob_refcnt is N + 1 +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:11: note: PyLongObject allocated at: value = PyLong_FromLong(1000); +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:10: note: when PyDict_New() succeeds at: dict = PyDict_New(); +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:33:8: note: when taking False path at: if (!dict) { +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:11: note: reaching: value = PyLong_FromLong(1000); +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:11: note: when PyLong_FromLong() succeeds at: value = PyLong_FromLong(1000); +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:11: note: ob_refcnt is now refs: 1 + N where N >= 0 +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:38:8: note: when taking False path at: if (!value) { +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:35: note: reaching: if (-1 == PyDict_SetItemString(dict, "key", value)) { +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:35: note: when PyDict_SetItemString() succeeds at: if (-1 == PyDict_SetItemString(dict, "key", value)) { +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:35: note: ob_refcnt is now refs: 1 + N where N >= 1 +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:8: note: when taking False path at: if (-1 == PyDict_SetItemString(dict, "key", value)) { +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:5: note: reaching: return dict; +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:58:1: note: when returning +tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:28:1: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c.test-refcount-errors.html' diff --git a/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stdout.txt b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stdout.txt new file mode 100644 index 0000000..1dad097 --- /dev/null +++ b/tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stdout.txt @@ -0,0 +1,277 @@ +Trace 0: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() succeeds' + 'taking False path' + 'returning' + Return value: + repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))) + str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: refs: 1 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37 + r->ob_refcnt: refs: 1 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type'))) + Exception: + (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:28 + +Trace 1: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking True path' + 'taking False path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type'))) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 2: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37 + r->ob_refcnt: None + r->ob_type: None + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 3: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32' + 'taking False path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: None + r->ob_type: None + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type'))) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 4: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() succeeds' + 'taking False path' + 'PyDict_SetItemString() fails' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: None + r->ob_type: None + PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37: + repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37)) + str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37 + r->ob_refcnt: None + r->ob_type: None + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 5: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() fails' + 'taking True path' + 'taking False path' + 'taking True path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: refs: 0 + N where N >= 0 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) PyDict_New')) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 6: + Transitions: + 'PyDict_New() succeeds' + 'taking False path' + 'PyLong_FromLong() fails' + 'taking True path' + 'taking False path' + 'taking False path' + 'calling tp_dealloc on new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32: + repr(): RegionOnHeap('new ref from (unknown) PyDict_New', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) + str(): new ref from (unknown) PyDict_New allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32 + r->ob_refcnt: None + r->ob_type: None + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) + +Trace 7: + Transitions: + 'PyDict_New() fails' + 'taking True path' + 'taking True path' + 'taking True path' + 'returning' + Return value: + repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0) + str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57 + Region("region-for-arg-gcc.ParmDecl('self')"): + repr(): Region("region-for-arg-gcc.ParmDecl('self')") + str(): Region("region-for-arg-gcc.ParmDecl('self')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('self')")) + Region("region-for-arg-gcc.ParmDecl('args')"): + repr(): Region("region-for-arg-gcc.ParmDecl('args')") + str(): Region("region-for-arg-gcc.ParmDecl('args')") + r->ob_refcnt: refs: 0 + N where N >= 1 + r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region("region-for-type-of-arg-gcc.ParmDecl('args')")) + Exception: + RegionForGlobal(gcc.VarDecl('PyExc_MemoryError'))
1
0
0
0
← Newer
1
2
3
4
5
6
7
8
Older →
Jump to page:
1
2
3
4
5
6
7
8
Results per page:
10
25
50
100
200