Re: Oops... strange (to me) segfault problem



On Wed, Aug 04, 2004 at 02:23:27AM -0400, John Vetterli wrote:
It looks like you're corrupting the free store.

I suspect the first call to read() reads less than BLOCK_SZ bytes, in
which case offset gets incremented but the memory block doesn't get
resized, so the next call to read() overwrites the data after the end of
the memory block.  

This turned out to be (part of) the problem, because I was wrong about
the size of the pipe buffer.  It's 4k, not 8k.

Perhaps if you removed the "if ( status == BLOCK_SZ )" and resized
the memory block unconditionally ???

This was part of the solution, but not all of it.  I also had to get
my math right.  The size of the reallocated region needed to be offset
+ status + BLOCK_SZ.  I forgot to add the number of recently read
characters to the size of the region.  This is what happens when we
code at 4am...  ;-)

Thanks for getting me on the right track.  Problem fixed.


A note about my earlier messages being dropped, for those who were
curious:

My earlier posts were PGP-signed using the PGP-MIME method.  Since my
last message wasn't, and it made it through to the list, I conclude
that when the gnome.org mail server receives such messages, it
seems to drop them on the floor without notifying ANYONE.  That seems
like broken behavior to me, but I guess now I know better.  Of course,
since I'm not the sysadmin of that system and I'm just guessing, I
could be wrong.

-- 
Derek D. Martin
http://www.pizzashack.org/
GPG Key ID: 0x81CFE75D




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