Date: Sun, 1 Aug 2004 09:00:45 +0200 (CEST) From: Thierry Thomas <thierry@pompo.net> To: FreeBSD-gnats-submit@FreeBSD.org Cc: Alex Rodioukov <simuran@shaw.ca> Subject: ports/69865: devel/py-psyco: 1.2 is broken. Message-ID: <20040801070045.8F42122B8ED@ws90bj.pompo.net> Resent-Message-ID: <200408010710.i717AP3I066746@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 69865 >Category: ports >Synopsis: devel/py-psyco: 1.2 is broken. >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Aug 01 07:10:24 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Thierry Thomas >Release: FreeBSD 5.2.1-RELEASE-p9 i386 >Organization: Kabbale Eros >Environment: System: FreeBSD ws90bj.pompo.net 5.2.1-RELEASE-p9 FreeBSD 5.2.1-RELEASE-p9 #1: Tue Jul 13 18:16:08 CEST 2004 thierry@ws90bj.pompo.net:/usr/obj/usr/src/sys/WS90BJ-040102 i386 >Description: Python aborts with py-psyco-1.2. >How-To-Repeat: echo "import psyco" | python Fatal Python error: psyco: out of memory zsh: done echo "import psyco" | zsh: abort (core dumped) python >Fix: The following patch has been obtained from the author Armin Rigo and is available in Psyco's CVS. If the maintainer agrees, I shall commit it. --- py-psyco.diff begins here --- diff -urN devel/py-psyco.orig/Makefile devel/py-psyco/Makefile --- devel/py-psyco.orig/Makefile Sat Jul 31 21:42:56 2004 +++ devel/py-psyco/Makefile Sun Aug 1 08:48:51 2004 @@ -7,6 +7,7 @@ PORTNAME= psyco PORTVERSION= 1.2 +PORTREVISION= 1 CATEGORIES= devel python MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= psyco diff -urN devel/py-psyco.orig/files/patch-c::codemanager.c devel/py-psyco/files/patch-c::codemanager.c --- devel/py-psyco.orig/files/patch-c::codemanager.c Thu Jan 1 01:00:00 1970 +++ devel/py-psyco/files/patch-c::codemanager.c Sun Aug 1 08:41:48 2004 @@ -0,0 +1,85 @@ +--- c/codemanager.c.orig Tue Dec 2 17:46:39 2003 ++++ c/codemanager.c Sun Aug 1 08:41:16 2004 +@@ -2,21 +2,12 @@ + #include <ipyencoding.h> + + /*** Allocators for Large Executable Blocks of Memory ***/ +-/* Defaults, possibly overridden below */ +-#define LEBM_WITH_MMAP 0 /* assume memory executable by default */ +-#define LEBM_NUM_BIGBLOCKS 1 /* not too large blocks */ + + #ifndef MS_WINDOWS + /* Assume UNIX */ + # include <sys/mman.h> +-# if defined(MAP_ANONYMOUS) || defined(MAP_ANON) +-# undef LEBM_WITH_MMAP +-# undef LEBM_NUM_BIGBLOCKS +-# define LEBM_WITH_MMAP 1 /* use mmap() with PROT_EXEC */ +-# define LEBM_NUM_BIGBLOCKS 32 /* ask for 32MB at a time */ +-# ifndef MAP_ANONYMOUS +-# define MAP_ANONYMOUS MAP_ANON +-# endif ++# if defined(MAP_ANON) && !defined(MAP_ANONYMOUS) ++# define MAP_ANONYMOUS MAP_ANON + # endif + #endif + +@@ -42,22 +33,44 @@ + + static void allocate_more_buffers(codemanager_buf_t** bb) + { +- char* p; +- int i; +- +-#if LEBM_WITH_MMAP +- p = (char*) mmap(NULL, BIG_BUFFER_SIZE * LEBM_NUM_BIGBLOCKS, +- PROT_EXEC|PROT_READ|PROT_WRITE, +- MAP_PRIVATE|MAP_ANONYMOUS, 0, 0); +- if (p == MAP_FAILED) +- OUT_OF_MEMORY(); +-#else +- p = (char*) PyMem_MALLOC(BIG_BUFFER_SIZE * LEBM_NUM_BIGBLOCKS); +- if (!p) +- OUT_OF_MEMORY(); ++ char* p = NULL; ++ int num_bigblocks = 1; ++ ++#if defined(MAP_ANONYMOUS) && defined(MAP_PRIVATE) ++ /* if we have anonymous mmap's, try using that -- this is known ++ to fail on some platforms */ ++ static int mmap_works = -1; ++ if (mmap_works != 0) ++ { ++ num_bigblocks = 32; /* allocate 32MB at a time */ ++ p = (char*) mmap(NULL, BIG_BUFFER_SIZE * num_bigblocks, ++ PROT_EXEC|PROT_READ|PROT_WRITE, ++ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); ++ if (p == MAP_FAILED || p == NULL) ++ { ++ if (mmap_works == 1) ++ OUT_OF_MEMORY(); ++ mmap_works = 0; /* doesn't work */ ++ p = NULL; ++ num_bigblocks = 1; ++ /* note that some platforms *require* the allocation to be performed ++ by mmap, because PyMem_MALLOC() doesn't set the PROT_EXEC flag. ++ On these platforms we just hope that the first allocation is ++ successful, which sets mmap_works to 1; a failure in a subsequent ++ allocation correctly signals the OUT_OF_MEMORY. */ ++ } ++ else ++ mmap_works = 1; ++ } + #endif + +- for (i=0; i<LEBM_NUM_BIGBLOCKS; i++) ++ if (p == NULL) ++ { ++ p = (char*) PyMem_MALLOC(BIG_BUFFER_SIZE); ++ if (p == NULL) ++ OUT_OF_MEMORY(); ++ } ++ while (--num_bigblocks >= 0) + { + /* the codemanager_buf_t structure is put at the end of the buffer, + with its signature to detect overflows (just in case) */ --- py-psyco.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040801070045.8F42122B8ED>