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: David Allouche
Subject: Re: [Texmacs-dev] graphviz plugin broken?
Date: Fri, 2 Jan 2004 16:12:37 +0100
User-agent: Mutt/1.5.4i

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).

-- 
                                                            -- ddaa




reply via email to

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