Recent strstream regression: reversion needed?

Paolo Carlini pcarlini@unitus.it
Mon Jun 3 10:54:00 GMT 2002


> No. It's necessary. That memory is allocated, it needs to be cleaned up.
>
> Try adding
>
>	    _M_buf = buf;
>
> in strstreambuf::overflow. 
>
> I've a patch attached, but I have to run now. It's the above, with a
> strstream reformat. You might check it out if you're interested. I'll
> try to finish it up tomorrow. I think it'll do the job.


Hi Benjamin,

I see the point of your patch and, whereas I'm still convinced that 
simply returning to the old code would be a simpler and cleaner solution 
(note that, in the old code, ~strstreambuf() *calls* _M_free(eback()); 
therefore the memory *is* deallocated) I was confident that your patch 
would work.

However, to my puzzlement, your patch doesn't work for a modified 
testcase writing more, say the first 1000 integers and we are back to a 
segfault:

#include <strstream.h>

int main()
{
   strstream s;
   for (unsigned i=0 ; i!= 1000 ; ++i)
      s << i << std::endl;
   s << std::ends;

   return 0;
}

In the next hours I hope to make progress in understanding /why/!

Ciao, Paolo.




More information about the Libstdc++ mailing list