[tpop3d-discuss] SIGBUS

Chris Lightfoot chris at ex-parrot.com
Tue, 12 Aug 2003 21:10:54 +0100


On Tue, Aug 12, 2003 at 08:43:18PM +0100, Paul Makepeace wrote:
> On Tue, Aug 05, 2003 at 06:15:14PM +0100, Paul Makepeace wrote:
> > Aug  5 13:35:48 mythix tpop3d[3223]: quit: signal 7 post_fork = 1
> > Aug  5 13:35:48 mythix tpop3d[17561]: net_loop: child process 3223 killed by signal 7 (shouldn't happen)
> 
> Error turned out to exhibit when the mailspool was a multiple of
> PAGESIZE.
> 
> Try this,
> 
> --- mailspool.c 29 Jul 2003 13:16:05 -0000      1.45
> +++ mailspool.c 12 Aug 2003 19:39:52 -0000
> @@ -259,3 +259,4 @@
>  
> -    len += PAGESIZE - (len % PAGESIZE);
> +    if (len % PAGESIZE)
> +        len += PAGESIZE - (len % PAGESIZE);
>      if (!filemem) {

Well done. Thanks for that. I don't think your patch is
right, though; the SIGBUS is received because the code
reads off the end of the file (but still within the mapped
area). I'd mixed up len and len2 in the mailspool.c code:

diff -u -r1.45 mailspool.c
--- mailspool.c 29 Jul 2003 13:16:05 -0000      1.45
+++ mailspool.c 12 Aug 2003 20:09:41 -0000
@@ -282,7 +282,7 @@
     /* Extract all From lines from file */
     do {
         p += 2;
-        q = (char*)memchr(p, '\n', len - (p - filemem));
+        q = (char*)memchr(p, '\n', len2 - (p - filemem));
 
         if (q) {
             size_t o, l;

-- that'll teach me to call a variable `len2'.

I'll fix this -- and the variable names -- in CVS....

-- 
``You have to be careful with referendums;
  they don't always give the result you want''
  (Trevor Phillips, in a London mayoral debate)