Buggy sbspace() on 64bit builds?
Simon J. Gerraty
sjg at juniper.net
Fri Feb 6 16:27:16 UTC 2015
Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:
> >Any thoughts on what a fix should be for this?
>
> size_t or intptr_t ?
I don't think so, the bug lies in the fact that on 64bit long is much
bigger than the uint's that are being manipulated.
Using a result object the same size works.
Here's a simple demo of the problem:
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
uint a, b;
long r1;
int r2;
a = 1;
b = 2;
r1 = a - b;
r2 = a - b;
printf("r1=%ld\nr2=%d\n", r1, r2);
exit(0);
}
32bit version outputs:
r1=-1
r2=-1
64bit version outputs:
r1=4294967295
r2=-1
the r1 value is obviously not what is expected by the caller.
More information about the freebsd-arch
mailing list