public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64
@ 2023-10-23 17:37 bruno at clisp dot org
2023-10-23 18:48 ` [Bug libc/30990] " bruno at clisp dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2023-10-23 17:37 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
Bug ID: 30990
Summary: fesetexceptflag raises floating-point exception traps
on i386, x86_64
Product: glibc
Version: 2.35
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: bruno at clisp dot org
CC: drepper.fsp at gmail dot com
Target Milestone: ---
Created attachment 15189
--> https://sourceware.org/bugzilla/attachment.cgi?id=15189&action=edit
test case foo.c
According to ISO C 23 § 7.6.4.5, fesetexceptflag is supposed to set
floating-point exception flags without raising a trap.
"Like fesetexcept, this function does not raise floating-point exceptions,
but only sets the state of the flags."
That's not how glibc's implementation does it on 32-bit x86, 64-bit x86_64, and
powerpc/powerpc64/powerpc64le.
The powerpc/powerpc64/powerpc64le case is already being handled in
https://sourceware.org/bugzilla/show_bug.cgi?id=30988 . Therefore here let me
concentrate on x86 and x86_64.
How to reproduce:
1. Compile the attached program foo.c.
Compiling for 64-bit mode on x86_64 hosts, or for 32-bit mode on i386 hosts:
$ gcc -Wall foo.c -lm
Compiling for 32-bit mode on x86_64 hosts:
$ i686-linux-gnu-gcc -Wall foo.c -lm
or
$ gcc -m32 -Wall foo.c -lm
2. Run it.
$ ./a.out
Floating point exception
I think it is a hardware limitation that on i386 and x86_64 CPUs, setting
a floating-point exception flag in the 387 unit triggers a trap, when
traps are enabled for the particular exception. But setting a
floating-point exception flag in the SSE unit does not have this
problem, cf. glibc/sysdeps/x86_64/fpu/fesetexcept.c.
Therefore I would expect the fesetexceptflag() function to operate correctly
when the hardware has an SSE unit (determined e.g. like in
sysdeps/i386/fpu/ftestexcept.c).
And only in the case where the CPU has only the 387 unit, I would expect
the fesetexceptflag() function to return a non-zero value (as error indicator)
and not modify the 387 floating-point control register, when this is the
only way to avoid a trap.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/30990] fesetexceptflag raises floating-point exception traps on i386, x86_64
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
@ 2023-10-23 18:48 ` bruno at clisp dot org
2023-10-23 18:49 ` bruno at clisp dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2023-10-23 18:48 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
Bruno Haible <bruno at clisp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Host| |x86_64-linux-gnu,
| |i386-linux-gnu
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/30990] fesetexceptflag raises floating-point exception traps on i386, x86_64
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
2023-10-23 18:48 ` [Bug libc/30990] " bruno at clisp dot org
@ 2023-10-23 18:49 ` bruno at clisp dot org
2023-10-23 18:50 ` bruno at clisp dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2023-10-23 18:49 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
--- Comment #1 from Bruno Haible <bruno at clisp dot org> ---
Created attachment 15190
--> https://sourceware.org/bugzilla/attachment.cgi?id=15190&action=edit
proposed fix
Find attached a proposed fix.
Not tested within glibc, but I tested equivalent code in Gnulib.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/30990] fesetexceptflag raises floating-point exception traps on i386, x86_64
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
2023-10-23 18:48 ` [Bug libc/30990] " bruno at clisp dot org
2023-10-23 18:49 ` bruno at clisp dot org
@ 2023-10-23 18:50 ` bruno at clisp dot org
2023-10-23 19:20 ` adhemerval.zanella at linaro dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2023-10-23 18:50 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
Bruno Haible <bruno at clisp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=30989
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/30990] fesetexceptflag raises floating-point exception traps on i386, x86_64
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
` (2 preceding siblings ...)
2023-10-23 18:50 ` bruno at clisp dot org
@ 2023-10-23 19:20 ` adhemerval.zanella at linaro dot org
2023-10-23 19:25 ` bruno at clisp dot org
2023-12-19 18:37 ` adhemerval.zanella at linaro dot org
5 siblings, 0 replies; 7+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2023-10-23 19:20 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |adhemerval.zanella at linaro dot o
| |rg
--- Comment #2 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
(In reply to Bruno Haible from comment #1)
> Created attachment 15190 [details]
> proposed fix
>
> Find attached a proposed fix.
> Not tested within glibc, but I tested equivalent code in Gnulib.
Thanks, it seems to a correct approach. I will send a patch upstream with some
testing along with this proposed change.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/30990] fesetexceptflag raises floating-point exception traps on i386, x86_64
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
` (3 preceding siblings ...)
2023-10-23 19:20 ` adhemerval.zanella at linaro dot org
@ 2023-10-23 19:25 ` bruno at clisp dot org
2023-12-19 18:37 ` adhemerval.zanella at linaro dot org
5 siblings, 0 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2023-10-23 19:25 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
Bruno Haible <bruno at clisp dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #15190|0 |1
is obsolete| |
--- Comment #3 from Bruno Haible <bruno at clisp dot org> ---
Created attachment 15191
--> https://sourceware.org/bugzilla/attachment.cgi?id=15191&action=edit
proposed fix v2
proposed fix v2: fixes a mistake (I had forgotten that the __control_word has
the trap bits inverted).
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug libc/30990] fesetexceptflag raises floating-point exception traps on i386, x86_64
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
` (4 preceding siblings ...)
2023-10-23 19:25 ` bruno at clisp dot org
@ 2023-12-19 18:37 ` adhemerval.zanella at linaro dot org
5 siblings, 0 replies; 7+ messages in thread
From: adhemerval.zanella at linaro dot org @ 2023-12-19 18:37 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30990
Adhemerval Zanella <adhemerval.zanella at linaro dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |2.39
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
Assignee|unassigned at sourceware dot org |adhemerval.zanella at linaro dot o
| |rg
--- Comment #4 from Adhemerval Zanella <adhemerval.zanella at linaro dot org> ---
Fixed on 2.39 (787282dede7f134fdb22155cee0c35172e3e28f3).
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-12-19 18:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 17:37 [Bug libc/30990] New: fesetexceptflag raises floating-point exception traps on i386, x86_64 bruno at clisp dot org
2023-10-23 18:48 ` [Bug libc/30990] " bruno at clisp dot org
2023-10-23 18:49 ` bruno at clisp dot org
2023-10-23 18:50 ` bruno at clisp dot org
2023-10-23 19:20 ` adhemerval.zanella at linaro dot org
2023-10-23 19:25 ` bruno at clisp dot org
2023-12-19 18:37 ` adhemerval.zanella at linaro dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).