texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] graphviz plugin broken?


From: Joris van der Hoeven
Subject: Re: [Texmacs-dev] graphviz plugin broken?
Date: Fri, 2 Jan 2004 16:45:35 +0100 (CET)

On Fri, 2 Jan 2004, David Allouche wrote:
> On Fri, Jan 02, 2004 at 02:09:32PM +0100, Martin Costabel wrote:
> > I did some tests (I have the same problem as Gregory, with
> > texmacs-1.0.2.11 and graphviz-1.9 from Fink). It seems that ghostscript
> > crashes, because the postscript output of tm_graphviz is systematically
> > truncated at 1024 bytes.
> >
> > The problem lies in this kind of dynamic buffering of the output of
> > popen in the readfile() function. I don't know how realloc() works in
> > Linux, but in Darwin, it makes the buffer jump around, i.e. after the
> > first realloc, wbuf and buf are no longer pointing to the same place, in
> > general, and disaster follows.
>
> What you describe sounds really like a bug in TeXmacs.  realloc() _does
> not_ garantee that the realloced buffer will stay at the same address.
>
> Some people even argue it is misleading and dangerous and should not be
> used. It was put in the libc back when it was significant to be able to
> optimize the case where the reallocation did not move the buffer, so
> copying the contents was not necessary.
>
> The correct way to fix this problem is modifying the code using realloc
> so only one pointer is considered for ownership puposes (that is,
> getting the start-of-buffer address and free'ing the buffer).

address@hidden lib]$ source-grep realloc
/home/vdhoeven/texmacs/src/plugins/graphviz/src/tm_graphviz.c:    buf = 
(char*)realloc( buf, buflen);
/home/vdhoeven/texmacs/src/plugins/r/src/tm_r.c:    b->buf = (char *)realloc( 
b->buf, b->size ) ;
/home/vdhoeven/texmacs/src/plugins/r/src/tm_r.c:    b->buf = (char *)realloc( 
b->buf, b->size ) ;
/home/vdhoeven/texmacs/src/plugins/r/src/tm_r.c:    b->buf = (char *)realloc( 
b->buf, b->size ) ;
/home/vdhoeven/texmacs/src/plugins/r/src/tm_r.c:    b->buf = (char *)realloc( 
b->buf, b->size ) ;
/home/vdhoeven/texmacs/src/plugins/r/src/tm_r.c:    b->buf = (char *)realloc( 
b->buf, b->size ) ;

TeXmacs does not use realloc; only some plug-ins do, namely R and ... Graphviz.
If someone could correct this problem...





reply via email to

[Prev in Thread] Current Thread [Next in Thread]