Overview building errors

Jen Linkova jen at comp.chem.msu.su
Thu Sep 13 10:19:01 UTC 2001

On Thu, Sep 13, 2001 at 06:05:00PM +0900, Katsuhiro Kondou wrote:
> } I added some debugging fprintf(stderr..) at  OV3packgroup() to get
> } size of all NEW.IDX files we are writting to. Error with pwrite() and
> } pointer outside the process's allocated address space appears
> } even if NEW.IDX file did not exist and was created by open(..O_CREAT..) 
> } ans its size equal to 0. 
> And what errno you got?  I believe it's EINVAL in most OS'es.  So,

Why??? NEW_IDX file did not exists before OV3packgroup() was called.
This file was created because open() was called with O_CREAT.
So, before pwrite() was called this file (and file descriptor)
exits and has size equal to 0.

> } > Sep  6 17:05:46 smaug makehistory[8323]: [ID 131604 news.error] tradindexed: packgroup cant write to
> } > /usr/local/news/spool/overview/n/p/m/b/netscape.public.mozilla.builds-NEW.IDX: No such file or directory
> I suspect above case(ENOENT) differs from yours.

As I wrote at my first message, 'ENOENT' appears because of
'%m' used in syslog() function. But pwrite() _does_ not set errno.
It wrote less than requested, but just wrote something, so
it returns number of bytes _acctually_ written, and doesn't
set errno.
So, %m may contains some junks - from previous errors.
The promblem is in unspecified behavior of write() if
we try n bytes from (char * buffer), and buffer[k] points
outside of the process's allocated address space ( k < n).
On some system (such FreeBSD 4.*) we get EFAULT at
firts time we call write().  So, code 

 if (pwrite(fd, &gh->indexmem[ge->low - ge->base] , nbytes,
               sizeof(INDEXENTRY)*(ge->low - ge->base + delta - 1)) != nbytes) {
        syslog(L_ERROR, "tradindexed: packgroup cant write to %s: %m", newidx);

will work correct - none will be written, return value will be '-1'
 and errno will be set.
But on Linux 2.2.* 
k bytes will be written (and k will be return value) at
first time we call write()/pwrite(). Remember - it's
less than requested number of bytes to be written..So, we will get error
message.  It's just what I get - and what is possibly the problem 
of author of original message. 
If we write a loop trying to write all bytes we get '-1' and 
errno = EFAULT at second attempt. 

I changed pwrite.c - now there is a loop until all requested
data is written or -1 returned by write(2). So, I get 'Bad address'
error in logs now instead of 'No such file or directory' (with
original code).

I'm now trying to find why &gh->indexmem[ge->low - ge->base] + nbytes
is outside address space.  But it isn't clear for me ;-(

SY, Jen aka Furry

More information about the inn-workers mailing list