[interfacekit] Re: BMallocIO broken

> Hi,
>
> after almost two hours of debugging I finally found out, that not my
> new BRoster::Launch() code causes crashing my tests, nor does any
> class
> associated with BResources (though it happens to crash in that code),
> but that BMallocIO is the source of my pain.
>
> I commented out the DataIO.cpp from the build.
>
> Again, Stefano (you seem to be the author of that file), please be
> careful with basic classes like this or others may waste a lot of
> time.
> Please re-run at least the unit tests of the modules using the class
> in
> question (`find' and `grep' are your friends to find out which are
> concerned). In this case the BResources tests (libstoragetest.so)
> help
> to reproduce the crash.
>
> CU, Ingo

        (Disclaimer: I only spent 10 minutes looking at the code)

        Looking at the code for BMallocIO, it looks like it's resizing on a
Write() even if the new calculated size (ie position + bytes written)
is *less* blocks than are currently allocated.  So if you write a
multiple blocks, overwrite a bit at the beginning, and then try to read
near the end, you will get unpredictable results.

        Graham



Other related posts: