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

crash when running on modified community PCRE regexp library #292

Closed
matthargett opened this issue Sep 9, 2021 · 1 comment · Fixed by #293
Closed

crash when running on modified community PCRE regexp library #292

matthargett opened this issue Sep 9, 2021 · 1 comment · Fixed by #293
Labels
A-lints Area: Relating to a lint directly C-bug Category: Bug

Comments

@matthargett
Copy link
Contributor

matthargett commented Sep 9, 2021

When running selene on this code:
https://devforum.roblox.com/t/100a2-pcre2-based-regex-implemention-for-luau-a-better-string-pattern-library/872807/7

I was fixing a selene warning:

warning[empty_if]: empty if block
     ┌─ src/RegEx/init.lua:1894:1
1894 │ ╭ if not cacheSize then
1895 │ │ elseif cacheSize < 0 or cacheSize ~= cacheSize then

and started getting this crash:

RUST_BACKTRACE=full selene src/
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }', selene-lib/src/rules/bad_string_escape.rs:129:80
stack backtrace:
   0:        0x109292d44 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6a8908fa3ed6f9e8
   1:        0x1092b10ac - core::fmt::write::h4be00f71c5582919
   2:        0x10928cdca - std::io::Write::write_fmt::h49e76926070788f1
   3:        0x109294baf - std::panicking::default_hook::{{closure}}::h1577f0656e419c0e
   4:        0x1092946ad - std::panicking::default_hook::h1aef594179c4fd25
   5:        0x1092952b0 - std::panicking::rust_panic_with_hook::h10bc487d002f6c42
   6:        0x109294d55 - std::panicking::begin_panic_handler::{{closure}}::hf4cfa78c105ce648
   7:        0x1092931b8 - std::sys_common::backtrace::__rust_end_short_backtrace::h1df96a166e4351c4
   8:        0x109294cba - _rust_begin_unwind
   9:        0x1092d3bef - core::panicking::panic_fmt::hea8fe6c9e0720810
  10:        0x1092d3cd5 - core::result::unwrap_failed::h58357c1be19e8a7d
  11:        0x108ffc255 - <selene_lib::rules::bad_string_escape::BadStringEscapeVisitor as full_moon::visitors::Visitor>::visit_value::h7705d6a9d59e51ae
  12:        0x108f57a7c - <full_moon::ast::Value as full_moon::visitors::Visit>::visit::hfbfa5a712309c6c8
  13:        0x108f68f55 - full_moon::ast::visitors::<impl full_moon::visitors::Visit for full_moon::ast::Expression>::visit::h59ec5d6caa34aa57
  14:        0x108fca2b7 - <full_moon::ast::punctuated::Pair<T> as full_moon::visitors::Visit>::visit::h0ff0a91119ff1706
  15:        0x108f57bff - <full_moon::ast::Value as full_moon::visitors::Visit>::visit::hfbfa5a712309c6c8
  16:        0x108f68f55 - full_moon::ast::visitors::<impl full_moon::visitors::Visit for full_moon::ast::Expression>::visit::h59ec5d6caa34aa57
  17:        0x108fca2b7 - <full_moon::ast::punctuated::Pair<T> as full_moon::visitors::Visit>::visit::h0ff0a91119ff1706
  18:        0x108f57bff - <full_moon::ast::Value as full_moon::visitors::Visit>::visit::hfbfa5a712309c6c8
  19:        0x108f68f55 - full_moon::ast::visitors::<impl full_moon::visitors::Visit for full_moon::ast::Expression>::visit::h59ec5d6caa34aa57
  20:        0x108fca2b7 - <full_moon::ast::punctuated::Pair<T> as full_moon::visitors::Visit>::visit::h0ff0a91119ff1706
  21:        0x108f57bff - <full_moon::ast::Value as full_moon::visitors::Visit>::visit::hfbfa5a712309c6c8
  22:        0x108f68f55 - full_moon::ast::visitors::<impl full_moon::visitors::Visit for full_moon::ast::Expression>::visit::h59ec5d6caa34aa57
  23:        0x108fca2b7 - <full_moon::ast::punctuated::Pair<T> as full_moon::visitors::Visit>::visit::h0ff0a91119ff1706
  24:        0x108f57bff - <full_moon::ast::Value as full_moon::visitors::Visit>::visit::hfbfa5a712309c6c8
  25:        0x108f68f55 - full_moon::ast::visitors::<impl full_moon::visitors::Visit for full_moon::ast::Expression>::visit::h59ec5d6caa34aa57
  26:        0x108f2b6af - <(A,B) as full_moon::visitors::Visit>::visit::h4ad88bb7f24a3e83
  27:        0x108ffb863 - <selene_lib::rules::bad_string_escape::BadStringEscapeLint as selene_lib::rules::Rule>::pass::hdac45c0b4cca7844
  28:        0x108cfd665 - selene_lib::Checker<V>::test_on::h5d35db0b4f8daf43
  29:        0x108d52ff0 - selene::read_file::h7d486277c45b338c
  30:        0x108d4c998 - <F as threadpool::FnBox>::call_box::h58f78c904762d642
  31:        0x108ed3dcb - std::sys_common::backtrace::__rust_begin_short_backtrace::h866782205e6bdaea
  32:        0x108ed45d9 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h4d237c38049ec789
  33:        0x10929869b - std::sys::unix::thread::Thread::new::thread_start::h63f8b299c7b9d50c
  34:     0x7fff203208fc - __pthread_start

which I narrowed to this construct:

return {
	{
		source = [==[^[\000-\037]]==],
		tests = {
			{
				input = "\01B",
				matches = {{ index = 0, match = "\001" }},
			},
		},
	},
}

if you remove the \01B part of the string, analysis is fine.

@Kampfkarren Kampfkarren added C-bug Category: Bug A-lints Area: Relating to a lint directly labels Sep 9, 2021
@matthargett
Copy link
Contributor Author

A similar thing in the same file:

return {
	{
		source = [==[abc[\1]de]==],
		tests = {
			{
				input = "abc\1de",
				matches = {{ index = 0, match = "abc\001de" }},
			},
		},
	},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Relating to a lint directly C-bug Category: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants