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

crytic crashes when running on my project #84

Open
baseballlover723 opened this issue Sep 14, 2020 · 1 comment
Open

crytic crashes when running on my project #84

baseballlover723 opened this issue Sep 14, 2020 · 1 comment

Comments

@baseballlover723
Copy link

cryptic crashes when I run it on my project (https://github.com/baseballlover723/lol-worlds-draw/tree/failing_cryptic) when running bin/crytic -s src/lol/worlds/draw.cr spec/lol/worlds/draw_spec.cr

Running 9 mutations.
    ✅ NumberLiteralChange
        in src/lol/worlds/draw.cr:6:34
    ✅ NumberLiteralChange
        in src/lol/worlds/draw.cr:9:36
    ❌ NumberLiteralChange
        in src/lol/worlds/draw.cr:12:49
        The following change didn't fail the test-suite:
            @@ -8,7 +8,7 @@
                     Group.new
                   end
                 end
            -    def initialize(groups : StaticArray(Group, 4))
            +    def initialize(groups : StaticArray(Group, 0))
                   @groups = groups
                 end
                 def self.new(pull : JSON::PullParser)

    ✅ NumberLiteralChange
        in src/lol/worlds/draw.cr:25:15
    ✅ NumberLiteralChange
        in src/lol/worlds/draw.cr:28:18Unhandled exception: unexpected token: -1 (Crystal::SyntaxException)
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/lexer.cr:3090:9 in 'raise'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/lexer.cr:3089:5 in 'raise'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:6002:9 in 'unexpected_token'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:5998:5 in 'unexpected_token'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4782:9 in 'parse_atomic_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4715:7 in 'parse_atomic_type_with_suffix'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4702:7 in 'parse_union_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4938:7 in 'parse_atomic_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4715:7 in 'parse_atomic_type_with_suffix'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4702:7 in 'parse_union_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4958:9 in 'parse_type_arg'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4938:7 in 'parse_type_args'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4813:7 in 'parse_generic'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4808:7 in 'parse_generic'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4799:5 in 'parse_generic'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4740:9 in 'parse_atomic_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4715:7 in 'parse_atomic_type_with_suffix'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4702:7 in 'parse_union_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4938:7 in 'parse_bare_proc_type'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:1189:7 in 'parse_type_declaration'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:1227:9 in 'new_node_check_type_declaration'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:1164:9 in 'parse_atomic_without_location'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:925:7 in 'parse_atomic'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:608:7 in 'parse_atomic_with_method'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:600:9 in 'parse_prefix'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:582:5 in 'parse_pow'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:581:5 in 'parse_mul_or_div'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:545:7 in 'parse_add_or_sub'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:540:5 in 'parse_shift'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:539:5 in 'parse_logical_and'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:538:5 in 'parse_logical_or'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:537:5 in 'parse_cmp'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:536:5 in 'parse_equality'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:535:5 in 'parse_and'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:534:5 in 'parse_or'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:475:9 in 'parse_range'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:444:7 in 'parse_question_colon'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:328:7 in 'parse_op_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:324:5 in 'parse_op_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:260:7 in 'parse_expression'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:137:7 in 'parse_multi_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:113:7 in 'parse_expressions_internal'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4174:7 in 'parse_expressions'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:6024:7 in 'parse_class_def'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:1606:5 in 'parse_class_def'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:1084:15 in 'parse_atomic_without_location'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:925:7 in 'parse_atomic'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:608:7 in 'parse_atomic_with_method'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:600:9 in 'parse_prefix'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:582:5 in 'parse_pow'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:581:5 in 'parse_mul_or_div'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:545:7 in 'parse_add_or_sub'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:540:5 in 'parse_shift'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:539:5 in 'parse_logical_and'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:538:5 in 'parse_logical_or'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:537:5 in 'parse_cmp'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:536:5 in 'parse_equality'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:535:5 in 'parse_and'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:534:5 in 'parse_or'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:475:9 in 'parse_range'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:444:7 in 'parse_question_colon'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:328:7 in 'parse_op_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:324:5 in 'parse_op_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:260:7 in 'parse_expression'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:137:7 in 'parse_multi_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:113:7 in 'parse_expressions_internal'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4174:7 in 'parse_expressions'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:6024:7 in 'parse_module_def'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:1096:15 in 'parse_atomic_without_location'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:925:7 in 'parse_atomic'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:608:7 in 'parse_atomic_with_method'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:600:9 in 'parse_prefix'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:582:5 in 'parse_pow'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:581:5 in 'parse_mul_or_div'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:545:7 in 'parse_add_or_sub'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:540:5 in 'parse_shift'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:539:5 in 'parse_logical_and'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:538:5 in 'parse_logical_or'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:537:5 in 'parse_cmp'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:536:5 in 'parse_equality'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:535:5 in 'parse_and'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:534:5 in 'parse_or'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:475:9 in 'parse_range'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:444:7 in 'parse_question_colon'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:328:7 in 'parse_op_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:324:5 in 'parse_op_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:260:7 in 'parse_expression'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:137:7 in 'parse_multi_assign'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:126:17 in 'parse_expressions_internal'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:4174:7 in 'parse_expressions'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:84:21 in 'parse'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/parser.cr:24:7 in 'parse'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:23:19 in 'process'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:78:11 in 'visit'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/ast.cr:169:27 in 'accept_children'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/visitor.cr:28:11 in 'accept'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:24:9 in 'process'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:78:11 in 'visit'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/ast.cr:169:27 in 'accept_children'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/visitor.cr:28:11 in 'accept'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:24:9 in 'process'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:78:11 in 'visit'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/ast.cr:169:27 in 'accept_children'
  from ../../../../../../../usr/share/crystal/src/compiler/crystal/syntax/visitor.cr:28:11 in 'accept'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:24:9 in 'process'
  from lib/crytic/src/crytic/mutation/inject_mutated_subject_into_specs.cr:32:9 in 'to_mutated_source'
  from lib/crytic/src/crytic/mutation/isolated_mutation.cr:86:9 in 'mutated_specs_source'
  from lib/crytic/src/crytic/mutation/isolated_mutation.cr:58:45 in 'write_full_source_into_tempfile'
  from lib/crytic/src/crytic/mutation/isolated_mutation.cr:41:7 in 'run'
  from lib/crytic/src/crytic/mutation/isolated_mutation.cr:18:24 in 'run'
  from lib/crytic/src/crytic/runner/sequential.cr:20:18 in 'run_mutations_for_single_subject'
  from lib/crytic/src/crytic/runner/sequential.cr:38:11 in 'run_all_mutations'
  from lib/crytic/src/crytic/runner/sequential.cr:13:17 in 'run'
  from lib/crytic/src/crytic/command/test.cr:19:5 in 'execute'
  from lib/crytic/src/crytic/cli.cr:19:9 in 'run'
  from lib/crytic/src/crytic.cr:5:12 in '__crystal_main'
  from ../../../../../../../usr/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from ../../../../../../../usr/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from ../../../../../../../usr/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???

Crystal Info

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
@hanneskaeufler
Copy link
Owner

Hi @baseballlover723, thanks for reporting the bug. I just had a look and indeed, what happens is that we apply the NumberLiteralSignFlip mutation, which leads to

    @groups : StaticArray(Group, (-1*4))

which is not valid syntax in crystal. Actually, regardless of syntax, flipping the 4 to -4 isn't valid crystal either way and doesn't compile

In src/lol/worlds/draw.cr:6:15

 6 | @groups : StaticArray(Group, -4)
               ^
Error: can't instantiate StaticArray(T, N) with N = -4 (N must be positive)

I haven't taken such constructs (where e.g. changing a number leads to invalid syntax) into consideration so far. One way forward would be to allow disabling of mutators, as you suggested in #85. Or we could make mutators be aware of these cases and not mutate. That would be my preference for now, but not sure how to even know when changing the number would literal be invalid. I'll look around a bit to see what can be done ... :)

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

No branches or pull requests

2 participants