Issue #3039: cython / array.array bindings generate errors (pypy/pypy)
New issue 3039: cython / array.array bindings generate errors https://bitbucket.org/pypy/pypy/issues/3039/cython-arrayarray-bindings-gener... Shlomi Fish: Why [https://github.com/shlomif/primesieve-python/tree/array-pypy3](https://github.com/shlomif/primesieve-python/tree/array-pypy3) \(note the branch\) gives me <<ValueError: array.array size changed, may indicate binary incompatibility. Expected 72 from C header, got 24 from PyObject>> in pypy3 and works fine in cpython3? After I “#if 0” the check, I get a segfault: ```plaintext shlomif[ProjEuler]:~/progs/riddles/project-euler/git/project-euler/641$ gdb -args pypy3 641-v1.py GNU gdb (GDB) 8.2-8.mga7 (Mageia release 7) Copyright (C) 2018 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-mageia-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from pypy3...Reading symbols from /home/shlomif/Download/unpack/prog/python/pypy3.5-6.0.0-linux_x86_64-portable/bin/pypy3.5.debug...(no debugging symbols found)...done. (no debugging symbols found)...done. (gdb) r Starting program: /home/shlomif/Download/unpack/prog/python/pypy3.5-6.0.0-linux_x86_64-portable/bin/pypy3 641-v1.py Missing separate debuginfos, use: debuginfo-install glibc-2.29-14.mga8.x86_64 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Program received signal SIGSEGV, Segmentation fault. resize (n=26355869, self=0x8e3350) at primesieve/array/_array.cpp:1190 1190 PyMem_Resize(items, char, (size_t)(n * self->ob_descr->itemsize)); Missing separate debuginfos, use: debuginfo-install lib64bz2_1-1.0.6-13.mga7.x86_64 lib64xcrypt1-4.4.6-1.mga7.x86_64 lib64zlib1-1.2.11-7.mga7.x86_64 libgomp1-8.3.1-0.20190628.2.mga8.x86_64 libstdc++6-8.3.1-0.20190628.2.mga8.x86_64 (gdb) p self $1 = (arrayobject *) 0x8e3350 (gdb) p self[0] $2 = {ob_refcnt = 2305843009213693953, ob_pypy_link = 140737275159976, ob_type = 0x8bb840, ob_size = 262193, data = {ob_item = 0x0, as_floats = 0x0, as_doubles = 0x0, as_ints = 0x0, as_uints = 0x0, as_uchars = 0x0, as_schars = 0x0, as_chars = 0x0, as_ulongs = 0x0, as_longs = 0x0, as_ulonglongs = 0x0, as_longlongs = 0x0, as_shorts = 0x0, as_ushorts = 0x0, as_pyunicodes = 0x0, as_voidptr = 0x0}, allocated = 0, ob_descr = 0x4100015a90, weakreflist = 0x4000, ob_exports = -309255392} (gdb) p self[0].ob ob_descr ob_pypy_link ob_size ob_exports ob_refcnt ob_type (gdb) p self[0].ob_descr $3 = (arraydescr *) 0x4100015a90 (gdb) p self[0].ob_descr [0] Cannot access memory at address 0x4100015a90 (gdb) p items $4 = (void *) 0x0 (gdb) p n $5 = 26355869 (gdb) p self[0].ob_descr $6 = (arraydescr *) 0x4100015a90 (gdb) q A debugging session is active. ``` Thanks! Here is the offending code: ```python # import array import heapq import sys import time from bisect import bisect_right # from subprocess import PIPE, Popen # import primesieve import primesieve.array from six import print_ from six.moves import range # Tuple is (n,k) where n is the sum and k is the count. # pipe = Popen(["primesieve", "-p1", "2", "500000029"], stdout=PIPE).stdout # pipe = Popen("primesieve -p1 2 1000", shell=True, stdout=PIPE).stdout t1 = time.time() primes = primesieve.array.primes(500000029) print_(primes[0]) t2 = time.time() ```
participants (1)
-
Shlomi Fish