public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bruno at clisp dot org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug math/31022] New: feupdateenv (FE_DFL_ENV) crashes on riscv
Date: Wed, 01 Nov 2023 17:02:49 +0000	[thread overview]
Message-ID: <bug-31022-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31022

            Bug ID: 31022
           Summary: feupdateenv (FE_DFL_ENV) crashes on riscv
           Product: glibc
           Version: 2.37
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: math
          Assignee: unassigned at sourceware dot org
          Reporter: bruno at clisp dot org
  Target Milestone: ---

ISO C 23 § 7.6.6.4 says about feupdateenv:
"The argument envp shall point to an object set by a call to feholdexcept or
fegetenv, or equal a dynamic floating-point environment macro."

This means, it is valid to call feupdateenv (FE_DFL_ENV).

But this call crashes with SIGSEGV on riscv.

How to reproduce:
========================== foo.c ======================
#include <fenv.h>

int
main ()
{
  return feupdateenv (FE_DFL_ENV) != 0;
}
=======================================================
$ gcc -Wall foo.c -lm
$ ./a.out
Segmentation fault (core dumped)

The place where it crashes is obviously at
glibc/sysdeps/riscv/rvf/fenv_private.h line 126:

static __always_inline void
libc_feupdateenv_riscv (const fenv_t *envp)
{
  _FPU_SETCW (*envp | riscv_getflags ());   // <================ HERE
}

with envp being 0xffffffffffffffff.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-11-01 17:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 17:02 bruno at clisp dot org [this message]
2023-11-01 17:03 ` [Bug math/31022] " bruno at clisp dot org
2023-12-19 18:38 ` adhemerval.zanella at linaro dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31022-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).