https://bugs.kde.org/show_bug.cgi?id=476887

--- Comment #5 from Paul Floyd <pjfl...@wanadoo.fr> ---
I've made quite a few improvements, but there are a few things that I'm not
sure about.

First, a quick Valgrind syscall digression. For synchronous syscalls that read
and write memory, Valgrind will track pre- and post-syscall reads and
pre-syscall writes. The tracking allows it to flag reads of uninitialized
memory and to mark written memory as initialized. async reads are more
complicated since we can't use the post-syscall, we need something else to know
when to mark the memory as initialized.

I started looking at the Darwin implementation for aio_read but it looks fairly
seriously wrong to me. (I'll get to the vector versions in a bit).

The Darwin implementation does the following
- in pre-syscall aio_read it registers the read
- in pre-syscall aio_return it deregisters the read and if the deregistration
succeeds sets a global flag to true
- in post-syscall aio_return it checks the global flag and marks the memory as
initialized

I see two problems with that
1. the global flag looks unsafe if two or more aio_reads are in flight
2. I don't think that the user is obliged to call aio_return. To me that just
seems like an async error code - lots of software doesn't bother to check error
codes.

>From what I've seen there are 3 ways that users can check whether an aio_read
has completed or not
1. poll aio_error
2. wait for the read to finish using aio_suspend or aio_waitcomplete (I'm not
sure what the difference is between those two)
3. use the sigevent

Just checked my copy of Design and Implementation. aio_waitcomplete combines
suspend and return.
Can you confirm that after any of the 3 above the read will have completed and
the memory should be marked as initialized?

I haven't looked at the sigevent. That might be a significant amount of work to
support in Valgrind.

Back to the vector versions. I suppose that all of the above ways to indicate
completion also apply and that they are atomic (that is they only apply when
all of the vector of memory blocks have been read to).

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to