From owner-freebsd-hackers Thu Jun 19 10:26:07 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id KAA07067 for hackers-outgoing; Thu, 19 Jun 1997 10:26:07 -0700 (PDT) Received: from ui-gate.utell.co.uk (root@ui-gate.utell.co.uk [194.200.4.253]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id KAA07058; Thu, 19 Jun 1997 10:25:58 -0700 (PDT) Received: from utell.co.uk (shift.utell.net [97.3.0.21]) by ui-gate.utell.co.uk (8.7.6/8.7.3) with ESMTP id SAA05602; Thu, 19 Jun 1997 18:25:51 +0100 (BST) Received: (from brian@localhost) by utell.co.uk (8.8.5/8.8.5) id SAA00390; Thu, 19 Jun 1997 18:25:50 +0100 (BST) Date: Thu, 19 Jun 1997 18:25:50 +0100 (BST) Message-Id: <199706191725.SAA00390@utell.co.uk> Mime-Version: 1.0 X-Newsreader: knews 0.9.8 Reply-To: brian@awfulhak.org, brian@utell.co.uk Organization: Awfulhak Ltd. References: <33956BBB.1BB@nospam.com> <5n7bk7$osi@uriah.heep.sax.de> <339863C7.1DF5@nospam.com> <5nbrkn$2h6@uriah.heep.sax.de> <339D9548.7B07@nospam.com> <5ob5e7$31j@ui-gate.utell.co.uk> <5obor4$58o@ui-gate.utell.co.uk> From: brian@utell.co.uk (Brian Somers) Subject: Re: xperfmon++ problem (again) Newsgroups: comp.unix.bsd.freebsd.misc Cc: jmz@freebsd.org, freebsd-hackers@freebsd.org Content-Type: text/plain; charset=us-ascii Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk [cc'd to jmz@FreeBSD.org] [cc'd to freebsd-hackers@FreeBSD.org] [posted to comp.unix.bsd.freebsd.misc] In article <5obor4$58o@ui-gate.utell.co.uk>, brian@shift.utell.net (Brian Somers) writes: > > [cc'd to jmz@FreeBSD.org (the XFree86 maintainer for FreeBSD)] > [cc'd to freebsd-hackers@FreeBSD.org] > [posted to comp.unix.bsd.freebsd.misc] > > In article <5ob5e7$31j@ui-gate.utell.co.uk>, > brian@shift.utell.net (Brian Somers) writes: >> In article <339D9548.7B07@nospam.com>, >> Marvin Foster writes: >>> J Wunsch wrote: >>>> >>>> Marvin Foster wrote: >>>> >>>> > Sorry. I was doing this from memory. The message was >>>> > >>>> > Error: Cannot perform realloc >>>> >>>> Well, i was checking all ``Cannot'' messages in the source, and none >>>> didn't come close to what you've mentioned. >>>> >>>> Of course, there's a chance that it's a message from some X11 library. >>>> Sorry for not being more helpful, but all i can say is that it works >>>> for me (and used to work all the time). >>>> >>>> -- >>>> cheers, J"org >>>> >>>> joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE >>>> Never trust an operating system you don't have sources for. ;-) >>> >>> I did the following: >>> >>> [pozzo:/usr/home/mefoster] ldd /usr/X11R6/bin/xperfmon++ >>> /usr/X11R6/bin/xperfmon++: >>> -lXaw.6 => /usr/X11R6/lib/libXaw.so.6.1 (0x8022000) >>> -lXt.6 => /usr/X11R6/lib/libXt.so.6.0 (0x8058000) >>> -lXmu.6 => /usr/X11R6/lib/libXmu.so.6.0 (0x8099000) >>> -lX11.6 => /usr/X11R6/lib/libX11.so.6.1 (0x80a9000) >>> -lkvm.2 => /usr/lib/libkvm.so.2.0 (0x813f000) >>> -lc.3 => /usr/lib/libc.so.3.0 (0x8143000) >>> [pozzo:/usr/home/mefoster] >>> [pozzo:/usr/home/mefoster] strings /usr/X11R6/lib/libXt.so.6.0 | grep >>> realloc >>> realloc >>> _realloc >>> [pozzo:/usr/home/mefoster] strings /usr/X11R6/lib/libXt.so.6.0 | grep >>> perform >>> Cannot perform %s >>> [pozzo:/usr/home/mefoster] >>> >>> I'm sort of new to FreeBSD, and not very expert at unix debugging, but >>> I will keep looking into it and submit a problem report if I find >>> anything. >> >> Ouch. I just built XFree86-3.3, and I'm now getting this from knews. >> I rebuilt knews too - no change. >> >> It happens just after I press the post key !!!!!! >> >> This is on a RELENG_2_2 machine built June 15. Even setting >> /etc/malloc.conf to RAD doesn't yield any results - somethings >> lying - realloc didn't fail ! I'll post any findings. >> >> Here goes again *cringe* > > Well, xc/lib/Xt/Alloc.c does the realloc (in function XtRealloc). > I changed the diagnostic so that it says how much we're allocating, > and it comes out as zero ! Ah ha ! > > shift $ cd /tmp > shift $ cat >x.c < #include > #include > main() > { > char *x = (char *)malloc(0); > printf("%p\n", x); > x = (char *)realloc(x,0); > printf("%p\n", x); > return 0; > } > eof > shift $ cc -o x x.c > shift $ ./x > 0x4030 > 0x0 > shift $ > > Now this is *really* bad news AFAIK. X provides the following in > FreeBSD.cf: > #define Malloc0ReturnsNull NO > > but I don't know of any provisions for malloc returning a pointer > and realloc returning NULL :( > > We could always do a simple patch to this file, but is this the > right way to go ? FWIW, this is the patch - it solves my knews problem, but isn't *really* the right answer :| Copy it to /usr/ports/x11/XFree86/patches/patch-af, and just "make". *** lib/Xt/Alloc.c.orig Wed May 21 16:02:17 1997 --- lib/Xt/Alloc.c Thu Jun 19 18:18:22 1997 *************** *** 139,150 **** if (!size) size = 1; #endif return(XtMalloc(size)); ! } else if ((ptr = Xrealloc(ptr, size)) == NULL ! #if MALLOC_0_RETURNS_NULL ! && size ! #endif ! ) ! _XtAllocError("realloc"); return(ptr); } --- 139,149 ---- if (!size) size = 1; #endif return(XtMalloc(size)); ! } else if ((ptr = Xrealloc(ptr, size)) == NULL && size) { ! char Msg[25]; ! sprintf(Msg, "realloc(%u)", size); ! _XtAllocError(Msg); ! } return(ptr); } -- Brian Don't _EVER_ lose your sense of humour !