*BSD News Article 98044


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.netspace.net.au!news.mel.connect.com.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!news.nl.innet.net!INnl.net!feed1.news.innet.be!INbe.net!stns.news.pipex.net!warm.news.pipex.net!pipex!tank.news.pipex.net!pipex!news.utell.co.uk!usenet
From: brian@shift.utell.net (Brian Somers)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: xperfmon++ problem (again)
Date: 19 Jun 1997 17:25:49 GMT
Organization: Awfulhak Ltd.
Lines: 142
Message-ID: <5obq2t$5ef@ui-gate.utell.co.uk>
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>
Reply-To: brian@awfulhak.org, brian@utell.co.uk
NNTP-Posting-Host: shift.utell.net
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.8
Cc: jmz@freebsd.org, freebsd-hackers@freebsd.org
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:43157

[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 <mefoster@nospam.com> writes:
>>> J Wunsch wrote:
>>>> 
>>>> Marvin Foster <mefoster@nospam.com> 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 <<eof
> #include <string.h>
> #include <stdio.h>
> 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 <brian@awfulhak.org> <brian@freebsd.org>
      <http://www.awfulhak.org>
Don't _EVER_ lose your sense of humour !