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

fix rawbigints #51122

Merged
merged 1 commit into from
Sep 1, 2023
Merged

fix rawbigints #51122

merged 1 commit into from
Sep 1, 2023

Conversation

nsajko
Copy link
Contributor

@nsajko nsajko commented Aug 31, 2023

Using Ptr like that was incorrect. Among other issues, a Ptr doesn't own the data it points to, so hold a String instead.

Fixes #51111

@nsajko
Copy link
Contributor Author

nsajko commented Aug 31, 2023

There's significant performance degradation for Float64 in particular, so I'll add some @inbounds.

@nsajko
Copy link
Contributor Author

nsajko commented Aug 31, 2023

Ended up removing the boundschecking altogether. It seemed simpler than sprinkling @inbounds all over, and the lack of bounds checking for rawbigints didn't seem to cause any bugs anyway.

@giordano giordano added needs tests Unit tests are required for this change domain:bignums BigInt and BigFloat labels Aug 31, 2023
base/rawbigints.jl Outdated Show resolved Hide resolved
@nsajko
Copy link
Contributor Author

nsajko commented Aug 31, 2023

Regarding the needs tests label, my current minimal reproducer for #51111 is:

using StochasticRounding, OrdinaryDiffEq
const SR = Float32sr
OrdinaryDiffEq.Tsit5ConstantCacheActual(SR, SR)

To make it amenable for inclusion into Julia's test suite, it would be necessary to get rid of the two package dependencies. This seems like it would be quite time consuming, while risking ending up with a huge reproducer in the end.

I tried to remove the dependency on OrdinaryDiffEq, with minimal changes, and ended up with a non-reproducer in the process. So what I'm trying to say is, this is (I guess so, at least) a difficult-to-reproduce heisenbug caused by undefined behavior, is it really worth it trying to add a test here?

@maleadt
Copy link
Member

maleadt commented Aug 31, 2023

Regarding the needs tests label, my current minimal reproducer for #51111 is:

using StochasticRounding, OrdinaryDiffEq
const SR = Float32sr
OrdinaryDiffEq.Tsit5ConstantCacheActual(SR, SR)

Why not the MWE I reduced it to? There's a couple of tests that require separate packages already, so you could mimic what they do.

Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

LGTM. There should be similar tests in precompile. There is already a abigfloat_x value, it looks like you just need to add some code to exercise this path (whereas currently it only tests addition).

Using `Ptr` like that was incorrect. Among other issues, a `Ptr`
doesn't own the data it points to, so hold a `String` instead.

Fixes JuliaLang#51111
@nsajko
Copy link
Contributor Author

nsajko commented Aug 31, 2023

Added the test based on the MWE by @maleadt to the location suggested by @vtjnash. Thanks.

Why not the MWE I reduced it to?

I misunderstood your MWE back then and thought I couldn't reproduce the issue using it.

@vtjnash vtjnash added status:merge me PR is reviewed. Merge when all tests are passing backport 1.10 Change should be backported to the 1.10 release and removed needs tests Unit tests are required for this change backport 1.10 Change should be backported to the 1.10 release labels Aug 31, 2023
@DilumAluthge DilumAluthge merged commit ec2f1d3 into JuliaLang:master Sep 1, 2023
9 of 10 checks passed
@DilumAluthge DilumAluthge removed the status:merge me PR is reviewed. Merge when all tests are passing label Sep 1, 2023
@nsajko nsajko deleted the g branch September 2, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:bignums BigInt and BigFloat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation fault during native BigFloat to Float32 conversion
6 participants