|
From: <jon...@ph...> - 2003-10-03 18:20:36
|
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
--
|
|
From: Dirk M. <dm...@gm...> - 2003-10-03 23:05:37
|
On Friday 03 October 2003 20:16, jon...@ph... wrote: > 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. hmm. do you know when this problem was introduced for you? do you use CVS HEAD or the 2_0 branch? > |