[prev in list] [next in list] [prev in thread] [next in thread] 

List:       netbsd-help
Subject:    Re: reproduceable "integer divide fault trap": solved
From:       "Jonathan A. Kollasch" <jakllsch () kollasch ! net>
Date:       2005-11-27 20:41:46
Message-ID: 20051127204146.GA9614 () vergon ! kollasch ! net
[Download RAW message or body]


On Sun, Nov 27, 2005 at 12:47:52AM -0500, Christos Zoulas wrote:
> Good catch. I think that is a gcc bug. Can you try changing the code
> so that the comparison is between 2 64 bit quantities?

I changed:

cgsize = fs->fs_fsize * fs->fs_fpg;
to
cgsize = (int64_t)fs->fs_fsize * (int64_t)fs->fs_fpg;

dirsize = fs->fs_avgfilesize * fs->fs_avgfpdir;
to
dirsize = (int64_t)fs->fs_avgfilesize * (int64_t)fs->fs_avgfpdir;

if (dirsize < curdirsize)
to
if (dirsize < (int64_t)curdirsize)

mkdir(1) now works fine. Notably I tested the cgsize and dirsize variables with
and without the casts and they indeed differ on my wd1e slice. I'm not
sure if the cast in the "if" expression is necessary but I'd rather be safe
than dividing by zero. Thanks to David and Pavel for pointing out the dirsize
and cgsize problems. Thanks to all for your prompt help. I'll submit a PR with
these changes. For which branches should I request pullups?

	Jonathan Kollasch

here's the difference with and without the casts of a mkdir in a
2nd level directory of wd1e:

Nov 27 14:20:37 gallifrey /netbsd: cgsize 32b args 0xFFFFFFFFEF620000
Nov 27 14:20:37 gallifrey /netbsd: cgsize 64b args 0x5EF620000
Nov 27 14:20:37 gallifrey /netbsd: dirsize 32b args 0x0
Nov 27 14:20:37 gallifrey /netbsd: dirsize 64b args 0x800000000

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic