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

Brakeman hangs on some platforms #1818

Closed
stanley90 opened this issue Jan 19, 2024 · 5 comments
Closed

Brakeman hangs on some platforms #1818

stanley90 opened this issue Jan 19, 2024 · 5 comments

Comments

@stanley90
Copy link

Background

Brakeman version: 6.1.1
Rails version: 6.1.7.6
Ruby version: 3.1.4

Hanging or Slowness

Brakeman (4.10.0) has been hanging since I moved to a Macbook Pro M1, but the same scan worked on an Ubuntu server. Currently I upgraded to 6.1.1 and in addition to hanging locally, it now also hangs on an Azure Ubuntu 20 image (but still works on the Ubuntu 22 server).

I narrowed the problem down to an individual file, the scan works when the file is skipped. The exception after interrupting is:

Interrupted - exiting.
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/bundle/ruby/3.0.0/gems/sexp_processor-4.17.0/lib/sexp.rb:36:in `initialize'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/bundle/ruby/3.0.0/gems/sexp_processor-4.17.0/lib/sexp.rb:36:in `initialize'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:28:in `new'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:28:in `deep_clone'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:32:in `block in deep_clone'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:30:in `each'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:30:in `deep_clone'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:32:in `block in deep_clone'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:30:in `each'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:30:in `deep_clone'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:32:in `block in deep_clone'
/Users/stanley/.asdf/installs/ruby/3.1.4/lib/ruby/gems/3.1.0/gems/brakeman-6.1.1/lib/ruby_parser/bm_sexp.rb:30:in `each'

I can provide the file privately (it's a module included in several controllers).

@presidentbeef
Copy link
Owner

Just as a guess, the machines that work probably have more memory?

I'd be interested in looking at the file - you can send it to brakeman@presidentbeef.com 📧

@stanley90
Copy link
Author

Just as a guess, the machines that work probably have more memory?

Wouldn't bet on that, both have 16GB (though there is definitely a difference in how much stuff is running on which machine).

I'd be interested in looking at the file - you can send it to brakeman@presidentbeef.com 📧

Sending.

@presidentbeef
Copy link
Owner

@stanley90 Brakeman is struggling due to many conditional re-assignments to the same variable that also use the variable as part of the new value (e.g. x = f(x) if y - take a look at the first method in the file you shared). This is the most common performance issue I see.

I have a potential fix I'll add soon.

@stanley90
Copy link
Author

@presidentbeef Not the prettiest file, I know 🙂 I can then test it, if it helps.

@presidentbeef
Copy link
Owner

Fixed with #1820

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