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
32-bit Windows cannot handle Rfloat::na() #321
Comments
I will try to take a look at this. |
It is possible that it is converting to the legacy FPU type (f80)
which would collapse all NaN values into one.
NA_REAL is a special NaN which we test explicitly by looking at the bit
pattern.
Andy.
…On Thu, Nov 11, 2021 at 8:39 AM Ilia ***@***.***> wrote:
I will try to take a look at this.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#321 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL36XBNZTU2AMVB6KH7ZFLULN6MTANCNFSM5HZFWTPQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
So the issue is rather weird. Here is what I found: So in extendr tests I retrieved
9218868437227407266 # libR_sys::R_NaReal
9218868437227407266 # Rfloat::na()
9221120237041092514 # libR_sys::R_NaReal
9218868437227407266 # Rfloat::na() To me it seems that somehow when compiling for |
x64 & "$env:R_HOME\bin\x64\Rscript.exe" -e "rextendr::rust_eval('rprintln!(\`"{:?}\`", unsafe { libR_sys::R_NaReal.to_bits()});', dependencies = list(``libR-sys`` = '0.2.2'), extendr_deps = list(``extendr-api`` = list(git = 'https://github.com/extendr/extendr', branch = 'master')))"
9218868437227407266 x86 & "$env:R_HOME\bin\i386\Rscript.exe" -e "rextendr::rust_eval('rprintln!(\`"{:?}\`", unsafe { libR_sys::R_NaReal.to_bits()});', dependencies = list(``libR-sys`` = '0.2.2'), extendr_deps = list(``extendr-api`` = list(git = 'https://github.com/extendr/extendr', branch = 'master')))"
9218868437227407266 Extremely strange. |
fn main() {
extendr_engine::start_r();
println!("{:?}", unsafe { libR_sys::R_NaReal.to_bits() });
extendr_engine::end_r();
} This thing works correctly for both architectures and yields 9218868437227407266. |
writable::integers get_na() {
auto na = R_NaReal;
auto na_as_ulong = *((unsigned long long*)&na);
writable::integers out(2);
out[0] = (int)(na_as_ulong >> 32);
out[1] = (int)(na_as_ulong);
return out;
} > get_na()
[1] 2146435072 1954
|
|
The difference between 32- and 64- bit NAs is in the high DWORD.
UPD: I think I found an explanation but not yet the solution... |
You may have found a rust bug! Ross Ihaka's birthday breaks the build. |
Could you formulate this into a 3 line example without dependencies so that we can submit a bug report? |
@andy-thomason, this is not a bug. Check out the explanation I linked above. In simple terms, when we compile for x86 we observe FPU/CPU being 'smart' and setting NAN silent bit when reinterpreting So far it seems that it happens during compilation of I tried creating a tiny Rust library referencing Anyway, I will dig deeper when I have time, but at least now I have some understanding of what is going on (I was afraid we are having some sort of memory corruption or non-atomic access to 64-bit value when running 32-bit). See also Wiki |
@andy-thomason, you were right -- there is a four-line reproducible example, unbelievable. fn main() {
let expected_na_val = 0x7ff00000u64 << 32 | 1954;
assert_eq!(expected_na_val, f64::from_bits(expected_na_val).to_bits());
} cargo run --target i686-pc-windows-gnu
UPD: I also tested using different toolchains and no cross-compilation, same result
|
Or Which seems to exactly this thing! As I suspect, there is an 8087 register somewhere in the mix. If CRAN drop x86 support, this should go away with luck. |
Yeah, it definitely will go away, as well as a ton of other issues, as we will likely no longer cross-compile. Yet for now, I wonder if I can make it work correctly. |
So my survey of the topic revealed the following: signalling
quiet
The payload (mantissa) should be non-zero, so in R it is the birth year of the author ( As soon as we finish with |
c.f. #318 (comment)
For this reason, one ALTREP-related test is disabled. Let's not forget to re-enable this as well.
473ac05
The text was updated successfully, but these errors were encountered: