misc/92110: setcontext restore the carry flag
Tanaka Akira
akr at m17n.org
Sat Jan 21 12:30:05 PST 2006
>Number: 92110
>Category: misc
>Synopsis: setcontext restore the carry flag
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jan 21 20:30:03 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Tanaka Akira
>Release: FreeBSD 5.4
>Organization:
AIST
>Environment:
FreeBSD freebsd54.vmw 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May 8 10:21:06 UTC 2005 root at harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>Description:
On Pentium, getcontext saves EFLAGS and setcontext restores it.
When CF is set in EFLAGS, setcontext treats it as an system call error.
>How-To-Repeat:
% cat t.c
#include <stdlib.h>
#include <stdio.h>
#include <ucontext.h>
ucontext_t c;
int first;
volatile int carry_set;
int main()
{
first = 1;
carry_set = ~0;
carry_set += 1;
if (getcontext(&c) != 0) {
perror("getcontext");
exit(1);
}
printf("first:%d\n", first);
if (first == 0)
exit(0);
first = 0;
if (setcontext(&c) != 0) {
perror("setcontext");
exit(1);
}
printf("setcontext returns\n");
exit(1);
}
% gcc -march=pentium4 t.c
% ./a.out
first:1
setcontext: Unknown error: 0
If "carry_set += 1" is changed to "carry_set -= 1", it works fine:
% ./a.out
first:1
first:0
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list