LibtraceTeam / wandio

C library for simple and efficient file IO
GNU Lesser General Public License v3.0
17 stars 13 forks source link

iow-thread: do not use EMPTY buffer when closing #30

Closed pallas closed 5 years ago

pallas commented 5 years ago

In thread_consumer, when we exit the inner loop because the program is over, the current buffer must be EMPTY; otherwise, we would have exited the inner loop normally. This EMPTY buffer is then passed to wandio_wwrite, where an uninitialized memory read occurs.

Instead, jump right to the cleanup after the inner loop.

Found with Valgrind.

pallas commented 5 years ago

Actually, I'm missing something here and this causes the tests to fail.

pallas commented 5 years ago

Forcing wandiocat to flush iow resolves the test issue. However I don't yet know enough about the wandio semantics to understand why.

pallas commented 5 years ago

Ah, I see, there can be partial buffers here. Will update patch.

pallas commented 5 years ago

The latest patch fixes the uninitialized read with no changes to wandiocat and all the tests pass.

salcock commented 5 years ago

Merged into the develop branch (2b15037e696f10554a1c7788fa63a3b5ae33f23a).

Thanks very much for your PR :)