lamarche@ireq.hydro.qc.ca (08/03/90)
I have compiled X11R4 (original tapes) on my hp360 machine running HP-UX 7.0. Everything went fine. Then I compiled xrn (6.8) from comp.sources.x, everything went fine also. When I run xgc ( in mit/demo ) or xrn both programs abort. I get the message: Error: Cannot perform realloc When tracing the program with cdb I see that the program xgc stops in main (line 197) create_test_choice (line 134 ) somewhere in XtOverrideTranslations Does anyone have an idea of a solution to this problem? Thanks in advance. -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | Louis Lamarche, IREQ | lamarche@ireq.hydro.qc.ca | CP 1000, Varennes | or | QC, Canada, J3X 1S1 | 514-652-8077 (office) 514-324-2919 (home)
jwright@cfht.hawaii.edu (Jim Wright) (08/04/90)
lamarche@ireq.hydro.qc.ca writes: >I have compiled X11R4 (original tapes) on my hp360 machine >running HP-UX 7.0. Everything went fine. Then I compiled >xrn (6.8) from comp.sources.x, everything went fine also. >When I run xgc ( in mit/demo ) or xrn both programs abort. >I get the message: > Error: Cannot perform realloc >Does anyone have an idea of a solution to this problem? I was able to beat this same bug, with lots of email help from some folks at HP. (Sorry, can't find names right now.) The "problem" is that X may call one of the alloc() routines with a request for zero bytes of memory, but expects to get a valid pointer back. I consider this a bug in X and not in HP's alloc. To fix this, you have to define the pre-processor symbol MALLOC_0_RETURNS_NULL and recompile *ALL* of X as well as all of your applications. This worked wonders for me. Below are a bits from two pertinent files. /*---------------- extract from site.def file ----------------*/ STD_DEFINES = -Wc,-Nd4000,-Ns3000 -DMALLOC_0_RETURNS_NULL -DSYSV /*---------------- extract from X11/Xlibos.h -----------------*/ /*** char *malloc(), *realloc(), *calloc(), *alloca(); *** FIXED - jrw ***/ void *malloc(), *realloc(), *calloc(), *alloca(); /* * Note that some machines do not return a valid pointer for malloc(0), in * which case we provide an alternate under the control of the * define MALLOC_0_RETURNS_NULL. This is necessary because some * Xlib code expects malloc(0) to return a valid pointer to storage. */ #ifdef MALLOC_0_RETURNS_NULL # define Xmalloc(size) malloc(((size) > 0 ? (size) : 1)) # define Xrealloc(ptr, size) realloc((ptr), ((size) > 0 ? (size) : 1)) # define Xcalloc(nelem, elsize) calloc(((nelem) > 0 ? (nelem) : 1), (elsize)) #else # define Xmalloc(size) malloc((size)) # define Xrealloc(ptr, size) realloc((ptr), (size)) # define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) #endif -- Jim Wright jwright@quonset.cfht.hawaii.edu Canada-France-Hawaii Telescope Corp.