On Linux, valgrind complains about uninitialized bytes being passed to write():
==14689== Syscall param write(buf) points to uninitialised byte(s)
==14689== at 0x5C6132F: __libc_write (write.c:26)
==14689== by 0x5C6132F: write (write.c:24)
==14689== by 0x5656A09: cppcoro::detail::linux::message_queue::enqueue_message(void*, cppcoro::detail::linux::message_type) (linux.cpp:78)
==14689== by 0x564FB0B: cppcoro::io_service::post_wake_up_event() (io_service.cpp:748)
==14689== by 0x564F564: cppcoro::io_service::stop() (io_service.cpp:454)
...
==14689== Address 0x1ffefff044 is on thread 1's stack
==14689== in frame #1, created by cppcoro::detail::linux::message_queue::enqueue_message(void*, cppcoro::detail::linux::message_type) (linux.cpp:74)
The write() call is in
bool message_queue::enqueue_message(void* msg, message_type type)
{
message qmsg;
qmsg.m_type = type;
qmsg.m_ptr = msg;
int status = write(m_pipefd[1], (const char*)&qmsg, sizeof(message));
return status==-1?false:true;
}
where
struct message
{
enum message_type m_type;
void* m_ptr;
};
has padding bytes between its two members. These bytes are not initialized in qmsg, but still being written.
So the easiest solution would be to initialize all of qmsg's bytes:
message qmsg;
+ std::memset(&qmsg, 0, sizeof(qmsg));
qmsg.m_type = type;
qmsg.m_ptr = msg;
On Linux, valgrind complains about uninitialized bytes being passed to
write():The
write()call is inwhere
has padding bytes between its two members. These bytes are not initialized in
qmsg, but still being written.So the easiest solution would be to initialize all of
qmsg's bytes: