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

Do not depend on unbounded-delays on 64-bit architecture #344

Merged
merged 1 commit into from
Aug 8, 2022

Conversation

Bodigrim
Copy link
Collaborator

On 64-bit arch there is no point to depend on unbounded-delays: (maxBound :: Int) microseconds are almost 300 000 years. Not a terribly big deal, but shaving off a dependency is always nice. Basically, CI jobs for all packages, which use tasty, have one less thing to compile.

@Bodigrim
Copy link
Collaborator Author

Bodigrim commented Aug 7, 2022

@VictorCMiraldo @andreasabel this is ready for review.

Copy link
Collaborator

@VictorCMiraldo VictorCMiraldo left a comment

Choose a reason for hiding this comment

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

Pardon my delay, I just came back from holidays.
Shaving off a dependency is always nice and the changes are really small, thanks @Bodigrim!

@@ -171,7 +177,9 @@ executeTest action statusVar timeoutOpt inits fins = mask $ \restore -> do
, resultTime = fromIntegral t
, resultDetailsPrinter = noResultDetails
}
fromMaybe timeoutResult <$> timeout t a
-- If compiled with unbounded-delays then t' :: Integer, otherwise t' :: Int
let t' = fromInteger (min (max 0 t) (toInteger (maxBound :: Int64)))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the max 0 t necessary? Both System.Timeout.timeout and its unbounded-delays counterpart are fmap Just when the specified delay is less than zero.

That being said, it doesn't hurt to keep it there. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

max 0 t is to prevent underflow. Imagine t = -(2^63+1) :: Integer: previously it meant no delay, but without max 0 t it would be cast to 2^63-1 :: Int, a huge timeout.

@Bodigrim Bodigrim merged commit 9ad34aa into UnkindPartition:master Aug 8, 2022
@Bodigrim Bodigrim deleted the no-unbounded-delays branch August 8, 2022 20:09
ansi-terminal >= 0.9

-- No reason to depend on unbounded-delays on 64-bit architecture
if(!arch(x86_64) && !arch(aarch64))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks brittle.
What are the possible values of arch? I couldn't even find the list in the cabal docs...
At least, checking it this way (with a whitelist) is conservative. But new architectures might easily fall under the radar.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Full list is here: https://hackage.haskell.org/package/Cabal-3.8.1.0/docs/src/Distribution.Simple.PreProcess.html#local-6989586621679281986

Potentially powerpc64, ia64 and s390x are also guaranteed to be 64-bit, but I decided to whitelist only architectures I have access to.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest to open an issue to potentially extend the list of recognized architectures, and whoever has access to one of them and can do testing can attack it.

@Bodigrim Bodigrim mentioned this pull request Dec 8, 2022
@andreasabel andreasabel added this to the core-1.4.3 milestone Dec 18, 2022
felixonmars added a commit to felixonmars/tasty that referenced this pull request Jun 22, 2023
64-bit RISC-V should fall into the same case in
UnkindPartition#344 and should be added
here. Tested locally.
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.

3 participants