Skip to content

riscv: Fix feholdexcept() #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlekseyZhmulin
Copy link

The feholdexcept() function must store the current floating point environment in *__envp.
Related to #321

Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.03%. Comparing base (3cfad14) to head (188b8f4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #324   +/-   ##
=======================================
  Coverage   39.03%   39.03%           
=======================================
  Files         233      233           
  Lines        6151     6151           
  Branches     1608     1608           
=======================================
  Hits         2401     2401           
  Misses       3397     3397           
  Partials      353      353           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@inkydragon inkydragon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're doing the same thing as BSD.
I'm not sure this works.

https://github.com/freebsd/freebsd-src/blob/master/lib/msun/riscv/fenv.h#L188-L195

@AlekseyZhmulin
Copy link
Author

AlekseyZhmulin commented May 9, 2025

The problem is that feholdexcept() does not save floating point environment, but feupdateenv() loads floating point environment. Therefore, in the lrint() function, "fenv_t env" is not initialized and a random value from the stack is loaded into the fcsr register. https://github.com/JuliaMath/openlibm/blob/master/src/s_lrint.c#L59. This throws an "Illegal instruction" exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants