You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When setBuffer() is called with an argument of 0, which should behave similarly as the default behaviour when the function is not called when looking at the rest of the code, what happens is that outputBuffer is set as a well-behaving zero-length char array https://github.com/fmihpc/vlsv/blob/master/vlsv_writer.cpp#L830. This does not lead to the crashes otherwise detected.
Now looking at the top of setBuffer(), if the user calls setBuffer() a second time and there is data left in the buffer, it will be silently deallocated and a new one will be allocated. Should this call emptyBuffer() first? Or should the user simply be prevented from calling setBuffer() multiple times, and then the delete is not needed any more?
Until this is solved we recommend to call setBuffer(0) or with the desired buffer size once and only once before any writing sequence.
The text was updated successfully, but these errors were encountered:
Sorry I now saw that the default in Vlasiator is not 0. It actually crashes also with a buffer size manually set to 0. So the behaviour for zero buffer size is ill-defined and should be fixed, as it seemed to me that the assumed default in the code was to do the standard default writing if the buffer size is 0, which would also be a sensible expectation from the user side. Probably then the emptyBuffer() call at line 830 (and similar if there is) should be bypassed if the buffer size is set to 0.
When
setBuffer()
is not being called,outputBuffer
is a NULL pointer as initialised in the constructor. https://github.com/fmihpc/vlsv/blob/master/vlsv_writer.cpp#L53 It seems that this situation leads to malloc probblems/OOM crashes in Vlasiator in some cases when it tries to empty the buffer before writing at https://github.com/fmihpc/vlsv/blob/master/vlsv_writer.cpp#L549.When
setBuffer()
is called with an argument of 0, which should behave similarly as the default behaviour when the function is not called when looking at the rest of the code, what happens is thatoutputBuffer
is set as a well-behaving zero-lengthchar
array https://github.com/fmihpc/vlsv/blob/master/vlsv_writer.cpp#L830. This does not lead to the crashes otherwise detected.Now looking at the top of
setBuffer()
, if the user callssetBuffer()
a second time and there is data left in the buffer, it will be silently deallocated and a new one will be allocated. Should this callemptyBuffer()
first? Or should the user simply be prevented from callingsetBuffer()
multiple times, and then thedelete
is not needed any more?Until this is solved we recommend to call
setBuffer(0)
or with the desired buffer size once and only once before any writing sequence.The text was updated successfully, but these errors were encountered: