[pypy-commit] pypy default: remove write_all_code_objects, this method is not called when it does not exist
Author: Richard Plangger Branch: Changeset: r91968:ac3af78f56db Date: 2017-07-23 18:22 -0400 http://bitbucket.org/pypy/pypy/changeset/ac3af78f56db/ Log:remove write_all_code_objects, this method is not called when it does not exist diff --git a/pypy/module/_vmprof/__init__.py b/pypy/module/_vmprof/__init__.py --- a/pypy/module/_vmprof/__init__.py +++ b/pypy/module/_vmprof/__init__.py @@ -11,7 +11,6 @@ interpleveldefs = { 'enable': 'interp_vmprof.enable', 'disable': 'interp_vmprof.disable', -'write_all_code_objects': 'interp_vmprof.write_all_code_objects', 'is_enabled': 'interp_vmprof.is_enabled', 'get_profile_path': 'interp_vmprof.get_profile_path', 'stop_sampling': 'interp_vmprof.stop_sampling', diff --git a/pypy/module/_vmprof/interp_vmprof.py b/pypy/module/_vmprof/interp_vmprof.py --- a/pypy/module/_vmprof/interp_vmprof.py +++ b/pypy/module/_vmprof/interp_vmprof.py @@ -70,11 +70,6 @@ except rvmprof.VMProfError as e: raise VMProfError(space, e) -def write_all_code_objects(space): -""" Needed on cpython, just empty function here -""" -pass - def disable(space): """Disable vmprof. Remember to close the file descriptor afterwards if necessary. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: remove old files
Author: Richard Plangger Branch: Changeset: r91966:cb8f734c831d Date: 2017-07-23 16:27 -0400 http://bitbucket.org/pypy/pypy/changeset/cb8f734c831d/ Log:remove old files diff --git a/rpython/rlib/rvmprof/src/shared/rss_darwin.h b/rpython/rlib/rvmprof/src/shared/rss_darwin.h deleted file mode 100644 --- a/rpython/rlib/rvmprof/src/shared/rss_darwin.h +++ /dev/null @@ -1,31 +0,0 @@ -/* On OS X we can get RSS using the Mach API. */ -#include -#include -#include -#include - -static mach_port_t mach_task; - -static int setup_rss(void) -{ -mach_task = mach_task_self(); -return 0; -} - -static int teardown_rss(void) -{ -return 0; -} - -static long get_current_proc_rss(void) -{ -mach_msg_type_number_t out_count = MACH_TASK_BASIC_INFO_COUNT; -mach_task_basic_info_data_t taskinfo = { .resident_size = 0 }; - -kern_return_t error = task_info(mach_task, MACH_TASK_BASIC_INFO, (task_info_t)&taskinfo, &out_count); -if (error == KERN_SUCCESS) { -return (long)(taskinfo.resident_size / 1024); -} else { -return -1; -} -} diff --git a/rpython/rlib/rvmprof/src/shared/rss_unix.h b/rpython/rlib/rvmprof/src/shared/rss_unix.h deleted file mode 100644 --- a/rpython/rlib/rvmprof/src/shared/rss_unix.h +++ /dev/null @@ -1,38 +0,0 @@ -#include - -/* On normal Unices we can get RSS from '/proc//status'. */ -static int proc_file = -1; - -static int setup_rss(void) -{ -char buf[128]; - -sprintf(buf, "/proc/%d/status", getpid()); -proc_file = open(buf, O_RDONLY); -return proc_file; -} - -static int teardown_rss(void) { -close(proc_file); -proc_file = -1; -return 0; -} - -static long get_current_proc_rss(void) -{ -char buf[1024]; -int i = 0; - -if (lseek(proc_file, 0, SEEK_SET) == -1) -return -1; -if (read(proc_file, buf, 1024) == -1) -return -1; -while (i < 1020) { -if (strncmp(buf + i, "VmRSS:\t", 7) == 0) { -i += 7; -return atoi(buf + i); -} -i++; -} -return -1; -} diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_main.c b/rpython/rlib/rvmprof/src/shared/vmprof_main.c deleted file mode 100644 --- a/rpython/rlib/rvmprof/src/shared/vmprof_main.c +++ /dev/null @@ -1,30 +0,0 @@ -#ifdef VMPROF_UNIX - -#include -/* value: LSB bit is 1 if signals must be ignored; all other bits - are a counter for how many threads are currently in a signal handler */ -static long volatile signal_handler_value = 1; - -void vmprof_ignore_signals(int ignored) -{ -if (!ignored) { -__sync_fetch_and_and(&signal_handler_value, ~1L); -} else { -/* set the last bit, and wait until concurrently-running signal - handlers finish */ -while (__sync_or_and_fetch(&signal_handler_value, 1L) != 1L) { -usleep(1); -} -} -} - -long vmprof_enter_signal(void) -{ -return __sync_fetch_and_add(&signal_handler_value, 2L); -} - -long vmprof_exit_signal(void) -{ -return __sync_sub_and_fetch(&signal_handler_value, 2L); -} -#endif diff --git a/rpython/rlib/rvmprof/src/shared/vmprof_main.h b/rpython/rlib/rvmprof/src/shared/vmprof_main.h deleted file mode 100644 --- a/rpython/rlib/rvmprof/src/shared/vmprof_main.h +++ /dev/null @@ -1,549 +0,0 @@ -#pragma once - -/* VMPROF - * - * statistical sampling profiler specifically designed to profile programs - * which run on a Virtual Machine and/or bytecode interpreter, such as Python, - * etc. - * - * The logic to dump the C stack traces is partly stolen from the code in - * gperftools. - * The file "getpc.h" has been entirely copied from gperftools. - * - * Tested only on gcc, linux, x86_64. - * - * Copyright (C) 2014-2017 - * Antonio Cuni - anto.c...@gmail.com - * Maciej Fijalkowski - fij...@gmail.com - * Armin Rigo - ar...@tunes.org - * Richard Plangger - planri...@gmail.com - * - */ - -#define _GNU_SOURCE 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "vmprof.h" - -#include "vmp_stack.h" -#include "vmprof_getpc.h" -#include "vmprof_mt.h" -#include "vmprof_common.h" -#include "compat.h" - -#if defined(__unix__) -#include "rss_unix.h" -#elif defined(__APPLE__) -#include "rss_darwin.h" -#endif - -#if VMPROF_LINUX -#include -#endif - -// - -static void *(*mainloop_get_virtual_ip)(char *) = 0; -static int opened_profile(const char *interp_name, int memory, int proflines, int native, int real_time); -static void flush_codes(void); - -// - -RPY_EXTERN void vmprof_ignore_signals(int ignored); -RPY_EXTERN long vmprof_enter_signal(void); -RPY_EXTERN long vmprof_exit_signal(void); - -/* * - * functions to write a profile file compatible with gperftools - * * - */
[pypy-commit] pypy default: reapply fix
Author: Richard Plangger Branch: Changeset: r91967:e19ef006ba32 Date: 2017-07-23 16:46 -0400 http://bitbucket.org/pypy/pypy/changeset/e19ef006ba32/ Log:reapply fix diff too long, truncating to 2000 out of 2191 lines diff --git a/pypy/module/_vmprof/test/test__vmprof.py b/pypy/module/_vmprof/test/test__vmprof.py --- a/pypy/module/_vmprof/test/test__vmprof.py +++ b/pypy/module/_vmprof/test/test__vmprof.py @@ -115,3 +115,31 @@ assert fd1.read() == tmpfile.read() _vmprof.disable() assert _vmprof.get_profile_path() is None + +def test_stop_sampling(self): +import os +import _vmprof +tmpfile = open(self.tmpfilename, 'wb') +native = 1 +def f(): +import sys +import math +j = sys.maxsize +for i in range(500): +j = math.sqrt(j) +_vmprof.enable(tmpfile.fileno(), 0.01, 0, native, 0, 0) +# get_vmprof_stack() always returns 0 here! +# see vmprof_common.c and assume RPYTHON_LL2CTYPES is defined! +f() +fileno = _vmprof.stop_sampling() +pos = os.lseek(fileno, 0, os.SEEK_CUR) +f() +pos2 = os.lseek(fileno, 0, os.SEEK_CUR) +assert pos == pos2 +_vmprof.start_sampling() +f() +fileno = _vmprof.stop_sampling() +pos3 = os.lseek(fileno, 0, os.SEEK_CUR) +assert pos3 > pos +_vmprof.disable() + diff --git a/rpython/rlib/rvmprof/cintf.py b/rpython/rlib/rvmprof/cintf.py --- a/rpython/rlib/rvmprof/cintf.py +++ b/rpython/rlib/rvmprof/cintf.py @@ -20,7 +20,8 @@ compile_extra = ['-DRPYTHON_VMPROF', '-O3'] separate_module_files = [ -SHARED.join('symboltable.c') +SHARED.join('symboltable.c'), +SHARED.join('vmprof_unix.c') ] if sys.platform.startswith('linux'): separate_module_files += [ @@ -40,7 +41,7 @@ compile_extra += ['-DVMPROF_LINUX'] elif sys.platform == 'win32': compile_extra = ['-DRPYTHON_VMPROF', '-DVMPROF_WINDOWS'] -separate_module_files = [SHARED.join('vmprof_main_win32.c')] +separate_module_files = [SHARED.join('vmprof_win.c')] _libs = [] else: # Guessing a BSD-like Unix platform @@ -58,7 +59,9 @@ SHARED.join('compat.c'), SHARED.join('machine.c'), SHARED.join('vmp_stack.c'), -SHARED.join('vmprof_main.c'), +SHARED.join('vmprof_mt.c'), +SHARED.join('vmprof_memory.c'), +SHARED.join('vmprof_common.c'), # symbol table already in separate_module_files ] + separate_module_files, post_include_bits=[], diff --git a/rpython/rlib/rvmprof/src/rvmprof.c b/rpython/rlib/rvmprof/src/rvmprof.c --- a/rpython/rlib/rvmprof/src/rvmprof.c +++ b/rpython/rlib/rvmprof/src/rvmprof.c @@ -15,9 +15,9 @@ #include "shared/vmprof_get_custom_offset.h" #ifdef VMPROF_UNIX -#include "shared/vmprof_main.h" +#include "shared/vmprof_unix.h" #else -#include "shared/vmprof_main_win32.h" +#include "shared/vmprof_win.h" #endif diff --git a/rpython/rlib/rvmprof/src/shared/_vmprof.c b/rpython/rlib/rvmprof/src/shared/_vmprof.c --- a/rpython/rlib/rvmprof/src/shared/_vmprof.c +++ b/rpython/rlib/rvmprof/src/shared/_vmprof.c @@ -9,8 +9,8 @@ #include #include "_vmprof.h" +#include "vmprof_common.h" -static volatile int is_enabled = 0; static destructor Original_code_dealloc = 0; static PyObject* (*_default_eval_loop)(PyFrameObject *, int) = 0; @@ -18,9 +18,9 @@ #include "trampoline.h" #include "machine.h" #include "symboltable.h" -#include "vmprof_main.h" +#include "vmprof_unix.h" #else -#include "vmprof_main_win32.h" +#include "vmprof_win.h" #endif #include "vmp_stack.h" @@ -156,7 +156,7 @@ static void cpyprof_code_dealloc(PyObject *co) { -if (is_enabled) { +if (vmprof_is_enabled()) { emit_code_object((PyCodeObject *)co); /* xxx error return values are ignored */ } @@ -187,7 +187,7 @@ return NULL; } -if (is_enabled) { +if (vmprof_is_enabled()) { PyErr_SetString(PyExc_ValueError, "vmprof is already enabled"); return NULL; } @@ -217,13 +217,13 @@ return NULL; } -is_enabled = 1; +vmprof_set_enabled(1); Py_RETURN_NONE; } static PyObject * vmp_is_enabled(PyObject *module, PyObject *noargs) { -if (is_enabled) { +if (vmprof_is_enabled()) { Py_RETURN_TRUE; } Py_RETURN_FALSE; @@ -237,7 +237,7 @@ return NULL; } -is_enabled = 0; +vmprof_set_enabled(0); if (PyErr_Occurred()) return NULL; @@ -362,7 +362,7 @@ #ifdef VMPROF_UNIX static PyObject * vmp_get_profile_path(PyObject *module, PyObject *noargs) { PyObject * o; -if (is_enabled) { +if (vmprof_is_enabled()) { char buffer[4096]; buffer[0] = 0; ssize_t buffer_len = vmp_fd_to_path(vmp_profile_fileno(), buffer, 4096); @@ -382,21 +382,19 @@ insert_real_time_thread(PyObject *module, PyObject * n
[pypy-commit] pypy reverse-debugger: Fix for edc44ccff552: the previous fix in clibffi had no effect
Author: Armin Rigo Branch: reverse-debugger Changeset: r91969:a24d6c7000c8 Date: 2017-07-25 17:58 +0200 http://bitbucket.org/pypy/pypy/changeset/a24d6c7000c8/ Log:Fix for edc44ccff552: the previous fix in clibffi had no effect diff --git a/rpython/memory/gctransform/support.py b/rpython/memory/gctransform/support.py --- a/rpython/memory/gctransform/support.py +++ b/rpython/memory/gctransform/support.py @@ -1,4 +1,5 @@ from rpython.rtyper.lltypesystem import lltype +from rpython.rtyper.lltypesystem.lloperation import llop from rpython.rtyper.extregistry import ExtRegistryEntry from rpython.annotator import model as annmodel import os @@ -77,23 +78,19 @@ from rpython.rlib.rposix import c_write return c_write(fd, string, len(string)) -def destructor_failed(typename, e): -try: -write(2, "a destructor of type ") -write(2, typename) -write(2, " raised an exception ") -write(2, str(e)) -write(2, " ignoring it\n") -except: -pass -destructor_failed._dont_inline_ = True - def ll_call_destructor(destrptr, destr_v, typename): +llop.revdb_do_next_call(lltype.Void) try: destrptr(destr_v) except Exception as e: -destructor_failed(typename, e) -ll_call_destructor._revdb_do_all_calls_ = True +try: +write(2, "a destructor of type ") +write(2, typename) +write(2, " raised an exception ") +write(2, str(e)) +write(2, " ignoring it\n") +except: +pass def ll_report_finalizer_error(e): try: diff --git a/rpython/rlib/clibffi.py b/rpython/rlib/clibffi.py --- a/rpython/rlib/clibffi.py +++ b/rpython/rlib/clibffi.py @@ -4,6 +4,7 @@ from rpython.rtyper.tool import rffi_platform from rpython.rtyper.lltypesystem import lltype, rffi +from rpython.rtyper.lltypesystem.lloperation import llop from rpython.rtyper.tool import rffi_platform from rpython.rlib.unroll import unrolling_iterable from rpython.rlib.rarithmetic import intmask, is_emulated_long @@ -419,8 +420,8 @@ (what the real callback is for example), casted to VOIDP """ userdata = rffi.cast(USERDATA_P, ll_userdata) +llop.revdb_do_next_call(lltype.Void) userdata.callback(ll_args, ll_res, userdata) -_ll_callback._revdb_do_all_calls_ = True def ll_callback(ffi_cif, ll_res, ll_args, ll_userdata): rposix._errno_after(rffi.RFFI_ERR_ALL | rffi.RFFI_ALT_ERRNO) diff --git a/rpython/rtyper/lltypesystem/lloperation.py b/rpython/rtyper/lltypesystem/lloperation.py --- a/rpython/rtyper/lltypesystem/lloperation.py +++ b/rpython/rtyper/lltypesystem/lloperation.py @@ -593,6 +593,7 @@ 'revdb_dtoa': LLOp(sideeffects=False), 'revdb_modf': LLOp(sideeffects=False), 'revdb_frexp': LLOp(sideeffects=False), +'revdb_do_next_call': LLOp(), } # * Run test_lloperation after changes. * diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py --- a/rpython/translator/c/funcgen.py +++ b/rpython/translator/c/funcgen.py @@ -713,6 +713,10 @@ return gencsupp.cast_gcptr_to_int(self, op) return self.OP_CAST_POINTER(op) +def OP_REVDB_DO_NEXT_CALL(self, op): +self.revdb_do_next_call = True +return "/* revdb_do_next_call */" + def OP_LENGTH_OF_SIMPLE_GCARRAY_FROM_OPAQUE(self, op): return ('%s = *(long *)(((char *)%s) + sizeof(struct pypy_header0));' ' /* length_of_simple_gcarray_from_opaque */' diff --git a/rpython/translator/revdb/gencsupp.py b/rpython/translator/revdb/gencsupp.py --- a/rpython/translator/revdb/gencsupp.py +++ b/rpython/translator/revdb/gencsupp.py @@ -78,10 +78,11 @@ return 'RPY_REVDB_EMIT(%s, %s, %s);' % (normal_code, cdecl(tp, '_e'), value) def emit_residual_call(funcgen, call_code, v_result, expr_result): -if getattr(getattr(funcgen.graph, 'func', None), - '_revdb_do_all_calls_', False): +if hasattr(funcgen, 'revdb_do_next_call'): +del funcgen.revdb_do_next_call return call_code # a hack for ll_call_destructor() to mean - # that the calls should really be done + # that the calls should really be done. + # Also used in rpython.rlib.clibffi. # if call_code in ('RPyGilAcquire();', 'RPyGilRelease();'): # Could also work with a regular RPY_REVDB_CALL_VOID, but we ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy reverse-debugger: Added tag RevDB-pypy2.7-v5.6.2 for changeset a24d6c7000c8
Author: Armin Rigo Branch: reverse-debugger Changeset: r91970:b0b66add46af Date: 2017-07-25 18:14 +0200 http://bitbucket.org/pypy/pypy/changeset/b0b66add46af/ Log:Added tag RevDB-pypy2.7-v5.6.2 for changeset a24d6c7000c8 diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -38,3 +38,4 @@ d7724c0a5700b895a47de44074cdf5fd659a988f RevDB-pypy2.7-v5.4.1 aff251e543859ce4508159dd9f1a82a2f553de00 release-pypy2.7-v5.6.0 e90317857d27917bf840caf675832292ee070510 RevDB-pypy2.7-v5.6.1 +a24d6c7000c8099c73d3660857f7e3cee5ac045c RevDB-pypy2.7-v5.6.2 ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: A failing test that explains why test_subclass() leaks the class Sub
Author: Ronan Lamy Branch: cpyext-leakchecking Changeset: r91971:82d95ae3d2c8 Date: 2017-07-25 20:19 +0200 http://bitbucket.org/pypy/pypy/changeset/82d95ae3d2c8/ Log:A failing test that explains why test_subclass() leaks the class Sub diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c --- a/pypy/module/cpyext/test/array.c +++ b/pypy/module/cpyext/test/array.c @@ -2468,6 +2468,15 @@ Py_RETURN_NONE; } +static PyObject * +same_dealloc(PyObject *self, PyObject *args) +{ +PyObject *obj1, *obj2; +if (!PyArg_ParseTuple(args, "OO", &obj1, &obj2)) { +return NULL; +} +return PyLong_FromLong(obj1->ob_type->tp_dealloc == obj2->ob_type->tp_dealloc); +} /*** Install Module **/ @@ -2477,6 +2486,7 @@ {"readbuffer_as_string", (PyCFunction)readbuffer_as_string, METH_VARARGS, NULL}, {"get_releasebuffer_cnt", (PyCFunction)get_releasebuffer_cnt, METH_NOARGS, NULL}, {"create_and_release_buffer", (PyCFunction)create_and_release_buffer, METH_O, NULL}, +{"same_dealloc", (PyCFunction)same_dealloc, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL}/* Sentinel */ }; diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py --- a/pypy/module/cpyext/test/test_arraymodule.py +++ b/pypy/module/cpyext/test/test_arraymodule.py @@ -111,6 +111,18 @@ res = [1, 2, 3] * arr assert res == [2, 4, 6] +def test_subclass_dealloc(self): +module = self.import_module(name='array') +class Sub(module.array): +pass + +arr = Sub('i', [2]) +module.readbuffer_as_string(arr) +class A(object): +pass +assert not module.same_dealloc(arr, module.array('i', [2])) +assert module.same_dealloc(arr, A()) + def test_subclass(self): import struct module = self.import_module(name='array') ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: Tweak CPyBuffer.releasebuffer() to make ll2ctypes happy
Author: Ronan Lamy Branch: cpyext-leakchecking Changeset: r91962:c99247c01177 Date: 2017-07-25 11:58 +0200 http://bitbucket.org/pypy/pypy/changeset/c99247c01177/ Log:Tweak CPyBuffer.releasebuffer() to make ll2ctypes happy diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py --- a/pypy/interpreter/executioncontext.py +++ b/pypy/interpreter/executioncontext.py @@ -605,6 +605,7 @@ e.write_unraisable(space, where, w_obj) e.clear(space) # break up reference cycles else: +raise addrstring = w_obj.getaddrstring(space) msg = ("RPython exception %s in %s<%s at 0x%s> ignored\n" % ( str(e), where, space.type(w_obj).name, addrstring)) @@ -615,7 +616,7 @@ def make_finalizer_queue(W_Root, space): """Make a FinalizerQueue subclass which responds to GC finalizer events by 'firing' the UserDelAction class above. It does not -directly fetches the objects to finalize at all; they stay in the +directly fetches the objects to finalize at all; they stay in the GC-managed queue, and will only be fetched by UserDelAction (between bytecodes).""" diff --git a/pypy/module/cpyext/buffer.py b/pypy/module/cpyext/buffer.py --- a/pypy/module/cpyext/buffer.py +++ b/pypy/module/cpyext/buffer.py @@ -73,19 +73,24 @@ if self.needs_decref: if self.releasebufferproc: func_target = rffi.cast(releasebufferproc, self.releasebufferproc) -with lltype.scoped_alloc(Py_buffer) as pybuf: -pybuf.c_buf = self.ptr -pybuf.c_len = self.size -pybuf.c_ndim = cts.cast('int', self.ndim) -pybuf.c_shape = cts.cast('Py_ssize_t*', pybuf.c__shape) -pybuf.c_strides = cts.cast('Py_ssize_t*', pybuf.c__strides) -for i in range(self.ndim): -pybuf.c_shape[i] = self.shape[i] -pybuf.c_strides[i] = self.strides[i] -with rffi.scoped_str2charp( -self.format if self.format else "B") as fmt: -pybuf.c_format = fmt -generic_cpy_call(self.space, func_target, self.pyobj, pybuf) +size = rffi.sizeof(cts.gettype('Py_buffer')) +pybuf = lltype.malloc(rffi.VOIDP.TO, size, flavor='raw', zero=True) +pybuf = cts.cast('Py_buffer*', pybuf) +pybuf.c_buf = self.ptr +pybuf.c_len = self.size +pybuf.c_ndim = cts.cast('int', self.ndim) +pybuf.c_shape = cts.cast('Py_ssize_t*', pybuf.c__shape) +pybuf.c_strides = cts.cast('Py_ssize_t*', pybuf.c__strides) +for i in range(self.ndim): +pybuf.c_shape[i] = self.shape[i] +pybuf.c_strides[i] = self.strides[i] +fmt = rffi.str2charp(self.format if self.format else "B") +try: +pybuf.c_format = fmt +generic_cpy_call(self.space, func_target, self.pyobj, pybuf) +finally: +lltype.free(fmt, flavor='raw') +lltype.free(pybuf, flavor='raw') decref(self.space, self.pyobj) self.pyobj = lltype.nullptr(PyObject.TO) else: diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -109,9 +109,9 @@ except leakfinder.MallocMismatch as e: result = e.args[0] filtered_result = {} -for obj in result: +for obj, value in result.iteritems(): if not is_allowed_to_leak(self.space, obj): -filtered_result[obj] = result[obj] +filtered_result[obj] = value if filtered_result: raise leakfinder.MallocMismatch(filtered_result) assert not self.space.finalizer_queue.next_dead() diff --git a/rpython/tool/leakfinder.py b/rpython/tool/leakfinder.py --- a/rpython/tool/leakfinder.py +++ b/rpython/tool/leakfinder.py @@ -6,6 +6,7 @@ # So far, this is used for lltype.malloc(flavor='raw'). TRACK_ALLOCATIONS = False ALLOCATED = {} +TB_LINES = 76 class MallocMismatch(Exception): def __str__(self): @@ -13,8 +14,8 @@ dict2 = {} for obj, traceback in dict.items(): traceback = traceback.splitlines() -if len(traceback) > 8: -traceback = ['...'] + traceback[-6:] +if len(traceback) > TB_LINES + 2: +traceback = ['...'] + traceback[-TB_LINES:] traceback = '\n'.join(traceback)
[pypy-commit] pypy cpyext-leakchecking: revert debugging code committed by mistake
Author: Ronan Lamy Branch: cpyext-leakchecking Changeset: r91963:31b9aeebd66e Date: 2017-07-25 12:03 +0200 http://bitbucket.org/pypy/pypy/changeset/31b9aeebd66e/ Log:revert debugging code committed by mistake diff --git a/pypy/interpreter/executioncontext.py b/pypy/interpreter/executioncontext.py --- a/pypy/interpreter/executioncontext.py +++ b/pypy/interpreter/executioncontext.py @@ -605,7 +605,6 @@ e.write_unraisable(space, where, w_obj) e.clear(space) # break up reference cycles else: -raise addrstring = w_obj.getaddrstring(space) msg = ("RPython exception %s in %s<%s at 0x%s> ignored\n" % ( str(e), where, space.type(w_obj).name, addrstring)) @@ -616,7 +615,7 @@ def make_finalizer_queue(W_Root, space): """Make a FinalizerQueue subclass which responds to GC finalizer events by 'firing' the UserDelAction class above. It does not -directly fetches the objects to finalize at all; they stay in the +directly fetches the objects to finalize at all; they stay in the GC-managed queue, and will only be fetched by UserDelAction (between bytecodes).""" diff --git a/rpython/tool/leakfinder.py b/rpython/tool/leakfinder.py --- a/rpython/tool/leakfinder.py +++ b/rpython/tool/leakfinder.py @@ -6,7 +6,6 @@ # So far, this is used for lltype.malloc(flavor='raw'). TRACK_ALLOCATIONS = False ALLOCATED = {} -TB_LINES = 76 class MallocMismatch(Exception): def __str__(self): @@ -14,8 +13,8 @@ dict2 = {} for obj, traceback in dict.items(): traceback = traceback.splitlines() -if len(traceback) > TB_LINES + 2: -traceback = ['...'] + traceback[-TB_LINES:] +if len(traceback) > 8: +traceback = ['...'] + traceback[-6:] traceback = '\n'.join(traceback) dict2.setdefault(traceback, []) dict2[traceback].append(obj) @@ -59,7 +58,7 @@ if TRACK_ALLOCATIONS: frame = sys._getframe(framedepth) sio = cStringIO.StringIO() -traceback.print_stack(frame, limit=40, file=sio) +traceback.print_stack(frame, limit=10, file=sio) tb = sio.getvalue() ALLOCATED[obj] = tb ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: Filter out C functions
Author: Ronan Lamy Branch: cpyext-leakchecking Changeset: r91964:5bba19e669b0 Date: 2017-07-25 13:30 +0200 http://bitbucket.org/pypy/pypy/changeset/5bba19e669b0/ Log:Filter out C functions diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -84,10 +84,13 @@ def is_allowed_to_leak(space, obj): from pypy.module.cpyext.pyobject import from_ref from pypy.module.cpyext.api import cts +from pypy.module.cpyext.methodobject import W_PyCFunctionObject try: w_obj = from_ref(space, cts.cast('PyObject*', obj._as_ptr())) except: return False +if isinstance(w_obj, W_PyCFunctionObject): +return True # It's OK to "leak" some interned strings: if the pyobj is created by # the test, but the w_obj is referred to from elsewhere. return is_interned_string(space, w_obj) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy cpyext-leakchecking: Be more careful with refcounts in array.c
Author: Ronan Lamy Branch: cpyext-leakchecking Changeset: r91965:438c0c9af393 Date: 2017-07-25 14:09 +0200 http://bitbucket.org/pypy/pypy/changeset/438c0c9af393/ Log:Be more careful with refcounts in array.c diff --git a/pypy/module/cpyext/sequence.py b/pypy/module/cpyext/sequence.py --- a/pypy/module/cpyext/sequence.py +++ b/pypy/module/cpyext/sequence.py @@ -48,7 +48,7 @@ m as the message text. If the conversion otherwise, fails, reraise the original exception""" if isinstance(w_obj, W_ListObject): -# make sure we can return a borrowed obj from PySequence_Fast_GET_ITEM +# make sure we can return a borrowed obj from PySequence_Fast_GET_ITEM w_obj.convert_to_cpy_strategy(space) return w_obj try: @@ -313,7 +313,7 @@ self) w_clone.switch_to_object_strategy() return w_clone - + def copy_into(self, w_list, w_other): w_list.switch_to_object_strategy() w_list.strategy.copy_into(w_list, w_other) @@ -378,7 +378,7 @@ def is_empty_strategy(self): return False - + PyObjectList = lltype.Ptr(lltype.Array(PyObject, hints={'nolength': True})) diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c --- a/pypy/module/cpyext/test/array.c +++ b/pypy/module/cpyext/test/array.c @@ -1867,6 +1867,7 @@ int n = PyList_Size(obj1); PyObject *v = getarrayitem(obj2, 0); int i = ((PyIntObject*)v)->ob_ival; +Py_DECREF(v); PyObject * ret = PyList_New(n*i); for (ii = 0; ii < i; ii++) for (nn = 0; nn < n; nn++) @@ -1883,6 +1884,7 @@ int n = PyList_Size(obj2); PyObject *v = getarrayitem(obj1, 0); int i = ((PyIntObject*)v)->ob_ival; +Py_DECREF(v); PyObject * ret = PyList_New(n*i); for (ii = 0; ii < i; ii++) for (nn = 0; nn < n; nn++) @@ -1919,6 +1921,7 @@ int n = PyList_Size(obj1); PyObject *v = getarrayitem(obj2, 0); int i = ((PyIntObject*)v)->ob_ival; +Py_DECREF(v); PyObject * ret = PyList_New(n); for (nn = 0; nn < n; nn++) { @@ -1926,7 +1929,10 @@ if (PyInt_Check(v)) PyList_SetItem(ret, nn, PyLong_FromLong(i * ((PyIntObject*)v)->ob_ival)); else +{ +Py_INCREF(v); PyList_SetItem(ret, nn, v); +} } return ret; } @@ -1936,6 +1942,7 @@ int n = PyList_Size(obj2); PyObject *v = getarrayitem(obj1, 0); int i = ((PyIntObject*)v)->ob_ival; +Py_DECREF(v); PyObject * ret = PyList_New(n); for (nn = 0; nn < n; nn++) { @@ -1943,7 +1950,10 @@ if (PyInt_Check(v)) PyList_SetItem(ret, nn, PyLong_FromLong(i * ((PyIntObject*)v)->ob_ival)); else +{ +Py_INCREF(v); PyList_SetItem(ret, nn, v); +} } return ret; } ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit