Skip to content
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

NaN vs -NaN (negative NaN) on macOS/arm64 #2909

Open
mattjohnsonpint opened this issue Feb 6, 2025 · 2 comments
Open

NaN vs -NaN (negative NaN) on macOS/arm64 #2909

mattjohnsonpint opened this issue Feb 6, 2025 · 2 comments
Labels

Comments

@mattjohnsonpint
Copy link
Contributor

Bug description

Strange issue found while working on something unrelated. It seems that in certain cases, the compiler creates NaN on some platforms, and -NaN on others. This can lead to test failures.

I encountered it first here:
#2908 (comment)

But a search found that we've seen it before.
https://github.com/AssemblyScript/assemblyscript/pull/2352/files/403cae846a804c829b70bd2de388c3286cfdb899?diff=unified&w=0#r931976127

(wait about 5-10 seconds for GitHub to jump to the comment thread on that last link)

I'm not sure if this an macOS issue or an arm64 issue, but in both cases that was the platform. It does not occur on Linux or Windows x64.

Writing this up mostly so it doesn't get lost. I haven't found any practical implications yet. Some opinions about NaN vs -NaN seems to think it's not very important: https://stackoverflow.com/questions/21349847/positive-vs-negative-nans

Perhaps already fixed by a newer Binaryen implementation? 🤷

Steps to reproduce

On a macOS/arm64 machine:

npm run test:compiler -- std/math --create
git diff

Observe a bunch of changes like this:

-  f64.const -nan:0x8000000000000
+  f64.const nan:0x8000000000000

AssemblyScript version

v0.27.32

@CountBleck
Copy link
Member

CountBleck commented Feb 7, 2025

I can reproduce this on my Android phone via Termux (I knew I've experienced this issue before!).
It's definitely an arm64 thing, not macOS.

@HerrCai0907
Copy link
Member

Some hint, it happened during binaryen's optimization pass. It may cause by nodejs wasm / js engine.

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

No branches or pull requests

3 participants