Skip to content

stack overflow on fragment cycle #716

Closed
@qwerdenkerXD

Description

@qwerdenkerXD

Description

During validation aren't all fragment cycles detected.
This causes a stack overflow in latest beta [email protected]

Steps to reproduce

Validate the following query for your schema:

query Introspection{
  __schema {
    types {
      ...cycle
    }
  }
}

fragment cycle on __Type {
  kind
  ...frag
}

fragment frag on __Type {
  kind
  ofType {
    ...cycle
  }
}

Here a code sample.

Expected result

The validation should pass and in the diagnostics should be one like:

{
  "errors": [
    {
      "message": "compiler error: `cycle` fragment cannot reference itself",
      "locations": [
        {
          "line": 9,
          "column": 1
        }
      ]
    }
  ]
}

Actual result

In [email protected]:

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1]    2496 abort      ./target/debug/gus start -m testing/server

So the program crashes.

In [email protected]:
An internal error occurs because salsa detected this cycle, so still an error but no crashing stack overflow.
So in terminal it is:

panicked at .../salsa-0.16.1/src/lib.rs:490:48:
Internal error, cycle detected:

DatabaseKeyIndex { group_index: 3, query_index: 43, key_index: 3 }
DatabaseKeyIndex { group_index: 3, query_index: 44, key_index: 3 }
DatabaseKeyIndex { group_index: 3, query_index: 38, key_index: 1 }
DatabaseKeyIndex { group_index: 3, query_index: 43, key_index: 5 }
DatabaseKeyIndex { group_index: 3, query_index: 44, key_index: 5 }
DatabaseKeyIndex { group_index: 3, query_index: 31, key_index: 4 }
DatabaseKeyIndex { group_index: 3, query_index: 43, key_index: 6 }
DatabaseKeyIndex { group_index: 3, query_index: 44, key_index: 6 }
DatabaseKeyIndex { group_index: 3, query_index: 38, key_index: 2 }

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Here the code sample for this version.

Environment

  • Operating system and version: Ubuntu 20.04.6 LTS
  • Shell (bash/zsh/powershell): zsh
  • apollo-rs crate: apollo-compiler
  • Crate version: 1.0.0-beta.5

Metadata

Metadata

Assignees

Labels

apollo-compilerissues/PRs pertaining to semantic analysis & validationbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions