|
From: Paul A. C. <pa...@us...> - 2003-10-03 20:37:18
|
What is it that you are reading from? Could it be a separate or
subprocess which exits after sending the data? (I don't believe there's
any guarantee that data sent but not received before the sending process
exits will necessarily ever be received.) Perhaps the newer version of
Valgrind is slowing the receiving process down enough that the sender is
gone before the read() is attempted?
Just a guess.
Paul Clarke
On Fri, 2003-10-03 at 13:16, jon...@ph... wrote:
> Hi,
> I have some code that behaves incorrectly when run under recent
> versions of Valgrind. When run under old versions of Valgrind,
> or without Valgrind, it works.
>
> Here's the code, which is trying to read a fixed-size record from
> a socket:
>
> char * buf_ptr = buf;
> while (bytes_to_read > 0) {
>
> int num_read = read(fd, buf_ptr, bytes_to_read);
>
> assert (num_read != 0); // <<<====
>
> if (num_read < 0) {
> ... handle errors ...
> } else {
> bytes_to_read -= num_read;
> buf_ptr += num_read;
> }
> }
>
> The problem is that the assertion is being triggered. If I remove
> the assertion, then the code works fine (so at least some of the
> subsequent read()s must be succeeding).
>
> There is not an EOF condition, and number_of_bytes_to_read is a
> small nonzero positive integer, so according to the man page
> there is no way that read() should return zero.
>
> Has anyone else seen this behaviour? Has anyone found a fix?
>
> Please CC me on replies - I'm not subscribed to the list.
>
> Kind regards,
>
> Jon Foster
> --
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Valgrind-users mailing list
> Val...@li...
> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>
|