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

/\p{Latin}/ crashes mutator #1231

Closed
backus opened this issue Apr 26, 2021 · 3 comments
Closed

/\p{Latin}/ crashes mutator #1231

backus opened this issue Apr 26, 2021 · 3 comments
Assignees
Labels

Comments

@backus
Copy link
Contributor

backus commented Apr 26, 2021

Versions:

$ ruby -v
ruby 2.6.7p197 (2021-04-05 revision 67941) [x86_64-darwin20]

$ bundle exec mutant run -v
mutant-0.10.30

$ bundle list
Gems included by the bundle:
  * ast (2.4.2)
  * diff-lcs (1.4.4)
  * mutant (0.10.30)
  * mutant-license (0.1.1.1.3319570810364303218730943090542303819067.3)
  * mutant-rspec (0.10.30)
  * parser (3.0.1.0)
  * regexp_parser (2.1.1)
  * rspec (3.10.0)
  * rspec-core (3.10.1)
  * rspec-expectations (3.10.1)
  * rspec-mocks (3.10.2)
  * rspec-support (3.10.2)
  * unparser (0.6.0)

Source triggering crash:

module MutantCrash
  def self.crash_the_mutant
    /\p{Latin}/
  end
end

Crash:

$ bundle exec mutant run --include lib --require example --use rspec 'MutantCrash*'
No examples found.
/dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp.rb:24:in `to_ast': undefined method `to_ast' for Mutant::Mutator::Node::Generic:Class (NoMethodError)
Did you mean?  to_s
	from /dev/.rvm/gems/ruby-2.6.7/gems/regexp_parser-2.1.1/lib/regexp_parser/expression/subexpression.rb:32:in `each'
	from /dev/.rvm/gems/ruby-2.6.7/gems/regexp_parser-2.1.1/lib/regexp_parser/expression/subexpression.rb:32:in `each'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp/transformer.rb:67:in `map'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp/transformer.rb:67:in `children'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp/transformer/recursive.rb:15:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/procto.rb:19:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp/transformer.rb:36:in `to_ast'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp.rb:24:in `to_ast'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/ast/regexp.rb:50:in `expand_regexp_ast'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator/node/literal/regex.rb:34:in `mutate_body'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator/node/literal/regex.rb:22:in `dispatch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator.rb:47:in `initialize'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:78:in `new'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:78:in `new'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/abstract_type.rb:40:in `block in create_new_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/abstract_type.rb:40:in `block in create_new_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/abstract_type.rb:40:in `block in create_new_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/procto.rb:19:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator.rb:23:in `mutate'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator/node.rb:42:in `mutate_child'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator/node.rb:26:in `block in define_named_child'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator/node/define.rb:17:in `dispatch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator.rb:47:in `initialize'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:78:in `new'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:78:in `new'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/abstract_type.rb:40:in `block in create_new_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/abstract_type.rb:40:in `block in create_new_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/procto.rb:19:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/mutator.rb:23:in `mutate'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/subject.rb:15:in `mutations'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium/method_builder.rb:91:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium/method_builder.rb:91:in `block (3 levels) in create_memoized_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:62:in `block (3 levels) in fetch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:61:in `fetch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:61:in `block (2 levels) in fetch'
	from /dev/.rvm/rubies/ruby-2.6.7/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:60:in `block in fetch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:59:in `fetch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium.rb:59:in `fetch'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/adamantium/method_builder.rb:90:in `block (2 levels) in create_memoized_method'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/bootstrap.rb:43:in `each'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/bootstrap.rb:43:in `flat_map'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/bootstrap.rb:43:in `block in call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/either.rb:108:in `fmap'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/bootstrap.rb:40:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/cli/command/environment.rb:28:in `block in bootstrap'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/either.rb:115:in `bind'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/cli/command/environment.rb:28:in `bootstrap'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/cli/command/environment/run.rb:30:in `block in action'
	from /dev/.rvm/gems/ruby-2.6.7/gems/unparser-0.6.0/lib/unparser/either.rb:115:in `bind'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/cli/command/environment/run.rb:30:in `action'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/cli/command.rb:79:in `execute'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/lib/mutant/cli/command.rb:55:in `call'
	from /dev/.rvm/gems/ruby-2.6.7/gems/mutant-0.10.30/bin/mutant:47:in `<top (required)>'
	from /dev/.rvm/gems/ruby-2.6.7/bin/mutant:23:in `load'
	from /dev/.rvm/gems/ruby-2.6.7/bin/mutant:23:in `<main>'
	from /dev/.rvm/gems/ruby-2.6.7/bin/ruby_executable_hooks:22:in `eval'
	from /dev/.rvm/gems/ruby-2.6.7/bin/ruby_executable_hooks:22:in `<main>'
@mbj
Copy link
Owner

mbj commented Apr 26, 2021

Very likely an incomplete Regexp -> AST mapper, or a regression on mutants regexp support.

I think we need a bigger corpus test for regexps. I'll try to hook up the regexp_parser tests.

Thanks for the report.

@mbj mbj self-assigned this Apr 26, 2021
@mbj mbj added the bug label Apr 26, 2021
@mbj
Copy link
Owner

mbj commented Apr 29, 2021

I have a potential fix, hope to be able to push it up tomorrow.

@mbj
Copy link
Owner

mbj commented May 3, 2021

@backus Thanks for the report, released a fix and some improvements on the error reporting for similar cases with 0.10.31.

Happy mutating.

@mbj mbj closed this as completed May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants