-
Notifications
You must be signed in to change notification settings - Fork 16
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
!!! project
causes memory inconsistencies
#38
Comments
cc @sheaf who wrote |
I don't recall the exact details, but I think I saw an issue like this start happening with GHC 9.0 or 9.2. The issue went away with |
Yes, that fixes it … but why, that’s horrifying |
How can every entry in a list of records pulled out of |
The relevant GHC issue is #19413 (although that is for |
I’m trying to reproduce the problem in the test suite, but I don’t know how to trigger the mis-optimization |
Also |
@sheaf Do you by any chance have any time next week to create a minimal reproduction example for the GHC bug tracker? |
@sheaf I meant doing a video call to figure one out based on the |
@Profpatsch Could you try replacing, purely in this library, runST' :: (forall s. ST s a) -> a
runST' !s = runST s with import GHC.ST (ST(..))
import GHC.Exts (runRW#, lazy)
runST' :: (forall s. ST s a) -> a
runST' !(ST st) = case runRW# st of (# _, a #) -> lazy a If that works, I think that would be good evidence we need the same |
project
(and potentially alsoinject
, we haven’t verified`, will cause undefined behavior, which we noticed & verified in a production system.The bug only appears with optimizations enabled (only tested
-O2
), not in ghciI don’t have a minimal repro (yet), but I can describe what we did:
There was one function which loaded some data in
IO
, constructed a ist ofrec
, then before returning usedproject
to reduce unnecessary fields in every list element:And another function that pulled a subset of fields from the record, like this:
Let’s say the final data was
Then what would be actually returned was (!!):
now, if you rewrote the function to deeply evaluate the
project
ed record:It would again return
When we rewrote the original function to construct a new record instead of
project
ing:The problem went away.
The text was updated successfully, but these errors were encountered: