Skip to content

Add InstallPlan invariant assertion checking, revealing cyclic dep problem #4014

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

Merged
merged 3 commits into from
Oct 21, 2016

Conversation

dcoutts
Copy link
Contributor

@dcoutts dcoutts commented Oct 21, 2016

It turns out that the install plan elaboration is constructing cyclic plans in some cases. The effect is that executing the plan simply misses out anything that depends on the packages involved in the cycle. This is probably the cause of #3996

With this patch such cases will fail with an assertion such as:

internal error in InstallPlan.fromSolverInstallPlanWithProgress:
The following packages are involved in a dependency cycle
hspec-discover-2.3.1-da63d0b4e952e7949a113646e4af0aac925a4d864a1db650..

The cause is clearly in the caller of fromSolverInstallPlanWithProgress and the only caller of that is ProjectPlanning.elaborateInstallPlan. The problem appears to be to do with the intra-package dependencies. The hspec-discover-2.3.1 example is one where it has a lib and an exe and the exe depends on the lib. The resulting elaborated plan ends up with the lib component with a self-dependency which is clearly wrong.

@ezyang would you mind having a look?

For the moment we cannot use ghc-options at the top level in the
cabal.project since it applies to all packages not just local ones.
Until that is fixed, use a workaround of specifying it for the two
local packages of interest directly.
plus some minor related tidying up, such as fixing a few stray cases
where we still talked about "index" rather than "graph".
It turns out that the install plan elaboration is constructing cyclic
plans in some cases. The effect is that executing the plan simply misses
out anything that depends on the packages involved in the cycle. This is
probably the cause of haskell#3996

With this patch such cases will fail with an assertion such as:

internal error in InstallPlan.fromSolverInstallPlanWithProgress:
The following packages are involved in a dependency cycle
hspec-discover-2.3.1-da63d0b4e952e7949a113646e4af0aac925a4d864a1db650..

The cause is clearly in the caller of fromSolverInstallPlanWithProgress
and the only caller of that is ProjectPlanning.elaborateInstallPlan.
The problem appears to be to do with the intra-package dependencies.
@dcoutts dcoutts added this to the 2.0 milestone Oct 21, 2016
@ezyang
Copy link
Contributor

ezyang commented Oct 21, 2016

Travis failure is due to DNS outage.

@ezyang
Copy link
Contributor

ezyang commented Oct 21, 2016

LGTM.

@@ -223,17 +223,21 @@ type InstallPlan = GenericInstallPlan

-- | Smart constructor that deals with caching the 'Graph' representation.
--
mkInstallPlan :: Graph (GenericPlanPackage ipkg srcpkg)
mkInstallPlan :: (IsUnit ipkg, IsUnit srcpkg)
Copy link
Contributor

Choose a reason for hiding this comment

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

We can get more accurate location tracing by requiring a CallStack (WithCallStack)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought of that but couldn't be bothered with the CPP required given the call stack stuff only works with newer ghcs.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what Distribution.Compat.Stack is for ;)

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.

2 participants