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

Internal compiler error: combineAliases invalid args #2096

Closed
nqpz opened this issue Jan 22, 2024 · 2 comments
Closed

Internal compiler error: combineAliases invalid args #2096

nqpz opened this issue Jan 22, 2024 · 2 comments
Assignees

Comments

@nqpz
Copy link
Member

nqpz commented Jan 22, 2024

The program

entry main (x: i32): (i32, bool) =
  let when pred action orig = if pred
                              then action orig
                              else orig

  let action = when true (\(x, _) -> (x, true))

  in if true
     then action (x, false)
     else action (x, false)

results in this error message when run with futhark c from git:

Internal compiler error (unhandled IO exception).
Please report this at https://github.com/diku-dk/futhark/issues
combineAliases invalid args: (Scalar (Record (fromList [(Name "0",Scalar (Prim (Signed Int32))),(Name "1",Scalar (Prim Bool))])),Scalar (TypeVar (fromList [AliasBound {aliasVar = VName (Name "action") 4504},AliasFree {aliasVar = VName (Name "internal_app_result") 1},AliasFree {aliasVar = VName (Name "internal_app_result") 2},AliasFree {aliasVar = VName (Name "internal_app_result") 3},AliasFree {aliasVar = VName (Name "action") 4494},AliasFree {aliasVar = VName (Name "orig") 4496}]) (QualName {qualQuals = [], qualLeaf = VName (Name "t\8322") 4497}) []))
CallStack (from HasCallStack):
  error, called at src/Language/Futhark/TypeChecker/Consumption.hs:407:3 in futhark-0.26.0-inplace:Language.Futhark.TypeChecker.Consumption
@athas
Copy link
Member

athas commented Jan 22, 2024

An interesting but in retrospect obvious bug, and the most surprising thing is that we have not seen it before.

The issue arises when we have more specific aliasing information available than is truly needed; in this case because we combine specific aliasing information from a tuple with more generic aliasing information from a type variable. We can shrink the program to this:

entry main (x: i32): (i32, bool) =
  let localid x = x
  in if true
     then localid (x, false)
     else localid (x, false)

@athas
Copy link
Member

athas commented Jan 22, 2024

Oh, actually we do handle that, but I just forgot to make the relationship symmetric...

@athas athas closed this as completed in ad9669b Jan 22, 2024
@athas athas self-assigned this Jan 24, 2024
athas added a commit to 0undefined/futhark that referenced this issue Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants