Closed chaadow closed 1 year ago
We are also experiencing a segmentation fault with brakeman (5.3.1) on Ruby 3.2.0. It fails consistently locally on arm64-darwin-21
and periodically within the test suite environment on x86_64-linux
.
```
Loading scanner...
Processing application in /home/circleci/biggerpockets
Processing gems...
[Notice] Detected Rails 7 application
Processing configuration...
[Notice] Escaping HTML by default
Parsing files...
Detecting file types...
Processing initializers...
0/83 files processed
1/83 files processed
2/83 files processed
3/83 files processed
4/83 files processed
5/83 files processed
6/83 files processed
7/83 files processed
8/83 files processed
9/83 files processed
10/83 files processed
11/83 files processed
12/83 files processed
13/83 files processed
14/83 files processed
15/83 files processed
16/83 files processed
17/83 files processed
18/83 files processed
19/83 files processed
20/83 files processed
21/83 files processed
22/83 files processed
23/83 files processed
24/83 files processed
25/83 files processed
26/83 files processed
27/83 files processed
28/83 files processed
29/83 files processed
30/83 files processed
31/83 files processed
32/83 files processed
33/83 files processed
34/83 files processed
35/83 files processed
36/83 files processed
37/83 files processed
38/83 files processed
39/83 files processed
40/83 files processed
41/83 files processed
42/83 files processed
43/83 files processed
44/83 files processed
45/83 files processed
46/83 files processed
47/83 files processed
48/83 files processed
49/83 files processed
50/83 files processed
51/83 files processed
52/83 files processed
53/83 files processed
54/83 files processed
55/83 files processed
56/83 files processed
57/83 files processed
58/83 files processed
59/83 files processed
60/83 files processed
61/83 files processed
62/83 files processed
63/83 files processed
64/83 files processed
65/83 files processed
66/83 files processed
67/83 files processed
68/83 files processed
69/83 files processed
70/83 files processed
71/83 files processed
72/83 files processed
73/83 files processed
74/83 files processed
75/83 files processed
76/83 files processed
77/83 files processed
78/83 files processed
79/83 files processed
80/83 files processed
81/83 files processed
82/83 files processed
Processing libs...
0/1228 files processed
1/1228 files processed
2/1228 files processed
3/1228 files processed
4/1228 files processed
5/1228 files processed
6/1228 files processed
7/1228 files processed
8/1228 files processed
9/1228 files processed
10/1228 files processed
11/1228 files processed
12/1228 files processed
13/1228 files processed
14/1228 files processed
15/1228 files processed
16/1228 files processed
17/1228 files processed
18/1228 files processed
19/1228 files processed
20/1228 files processed
21/1228 files processed
22/1228 files processed
23/1228 files processed
24/1228 files processed
25/1228 files processed
26/1228 files processed
27/1228 files processed
(eval):2: [BUG] Segmentation fault at 0x000008a50000089c
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0103 p:0004 s:0543 e:000541 METHOD (eval):2
c:0102 p:0030 s:0537 e:000535 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:41 [FINISH]
c:0101 p:---- s:0531 e:000530 IFUNC
c:0100 p:---- s:0528 e:000527 CFUNC :each
c:0099 p:---- s:0525 e:000524 CFUNC :each_with_index
c:0098 p:0011 s:0521 e:000520 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:40
c:0097 p:0087 s:0516 e:000515 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/library_processor.rb:68
c:0096 p:0021 s:0510 e:000509 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0095 p:0010 s:0506 e:000505 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0094 p:0059 s:0501 e:000500 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0093 p:0017 s:0494 e:000490 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:50
c:0092 p:0021 s:0485 e:000484 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0091 p:0010 s:0481 e:000480 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0090 p:0059 s:0476 e:000475 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0089 p:0005 s:0469 e:000468 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:111 [FINISH]
c:0088 p:---- s:0465 e:000464 CFUNC :map!
c:0087 p:0012 s:0461 e:000460 METHOD (eval):3
c:0086 p:0016 s:0456 e:000455 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:110
c:0085 p:0021 s:0451 e:000450 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0084 p:0010 s:0447 e:000446 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0083 p:0059 s:0442 e:000441 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0082 p:0115 s:0435 e:000432 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:59
c:0081 p:0021 s:0427 e:000426 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0080 p:0010 s:0423 e:000422 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0079 p:0059 s:0418 e:000417 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0078 p:0005 s:0411 e:000410 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:111 [FINISH]
c:0077 p:---- s:0407 e:000406 CFUNC :map!
c:0076 p:0012 s:0403 e:000402 METHOD (eval):3
c:0075 p:0016 s:0398 e:000397 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:110
c:0074 p:0021 s:0393 e:000392 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0073 p:0010 s:0389 e:000388 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0072 p:0059 s:0384 e:000383 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0071 p:0115 s:0377 e:000374 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:59
c:0070 p:0021 s:0369 e:000368 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0069 p:0010 s:0365 e:000364 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0068 p:0059 s:0360 e:000359 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0067 p:0005 s:0353 e:000352 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:111 [FINISH]
c:0066 p:---- s:0349 e:000348 CFUNC :map!
c:0065 p:0012 s:0345 e:000344 METHOD (eval):3
c:0064 p:0016 s:0340 e:000339 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:110
c:0063 p:0021 s:0335 e:000334 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0062 p:0010 s:0331 e:000330 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0061 p:0059 s:0326 e:000325 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0060 p:0026 s:0319 e:000315 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:41 [FINISH]
c:0059 p:---- s:0311 e:000310 IFUNC
c:0058 p:---- s:0308 e:000307 CFUNC :each
c:0057 p:---- s:0305 e:000304 CFUNC :each_with_index
c:0056 p:0011 s:0301 e:000300 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:40
c:0055 p:0005 s:0296 e:000295 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/library_processor.rb:73
c:0054 p:0021 s:0290 e:000289 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0053 p:0010 s:0286 e:000285 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0052 p:0059 s:0281 e:000280 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0051 p:0005 s:0274 e:000273 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:111 [FINISH]
c:0050 p:---- s:0270 e:000269 CFUNC :map!
c:0049 p:0012 s:0266 e:000265 METHOD (eval):3
c:0048 p:0016 s:0261 e:000260 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:110
c:0047 p:0021 s:0256 e:000255 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0046 p:0010 s:0252 e:000251 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0045 p:0059 s:0247 e:000246 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0044 p:0026 s:0240 e:000236 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:41 [FINISH]
c:0043 p:---- s:0232 e:000231 IFUNC
c:0042 p:---- s:0229 e:000228 CFUNC :each
c:0041 p:---- s:0226 e:000225 CFUNC :each_with_index
c:0040 p:0011 s:0222 e:000221 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/base_processor.rb:40
c:0039 p:0005 s:0217 e:000216 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/library_processor.rb:73
c:0038 p:0021 s:0211 e:000210 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:76
c:0037 p:0010 s:0207 e:000206 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:113
c:0036 p:0059 s:0202 e:000201 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/ruby_parser/bm_sexp_processor.rb:72
c:0035 p:0015 s:0195 e:000194 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processors/library_processor.rb:21
c:0034 p:0013 s:0189 e:000188 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/processor.rb:98
c:0033 p:0013 s:0183 e:000182 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/scanner.rb:245
c:0032 p:0022 s:0178 e:000177 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/scanner.rb:239
c:0031 p:0021 s:0174 e:000173 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/scanner.rb:342 [FINISH]
c:0030 p:---- s:0170 e:000169 CFUNC :each
c:0029 p:0018 s:0166 e:000165 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/scanner.rb:339
c:0028 p:0029 s:0158 e:000157 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/scanner.rb:237
c:0027 p:0069 s:0154 e:000153 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/scanner.rb:55
c:0026 p:0075 s:0150 e:000149 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman.rb:392
c:0025 p:0052 s:0143 e:000142 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman.rb:86
c:0024 p:0016 s:0138 e:000137 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/commandline.rb:157
c:0023 p:0005 s:0133 e:000132 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/commandline.rb:125
c:0022 p:0020 s:0125 e:000124 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/commandline.rb:166
c:0021 p:0041 s:0119 e:000118 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/commandline.rb:35
c:0020 p:0030 s:0113 e:000112 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/lib/brakeman/commandline.rb:20
c:0019 p:0046 s:0107 e:000106 TOP /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/brakeman-5.3.1/bin/brakeman:10 [FINISH]
c:0018 p:---- s:0104 e:000103 CFUNC :load
c:0017 p:0078 s:0099 e:000098 TOP /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/bin/brakeman:25 [FINISH]
c:0016 p:---- s:0094 e:000093 CFUNC :load
c:0015 p:0064 s:0089 e:000088 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58
c:0014 p:0050 s:0083 e:000082 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:23
c:0013 p:0034 s:0078 e:000077 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/cli.rb:486
c:0012 p:0054 s:0073 e:000072 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/command.rb:27
c:0011 p:0040 s:0065 e:000064 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/invocation.rb:127
c:0010 p:0213 s:0058 e:000057 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor.rb:392
c:0009 p:0008 s:0045 e:000044 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/cli.rb:31
c:0008 p:0044 s:0040 e:000039 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/vendor/thor/lib/thor/base.rb:485
c:0007 p:0008 s:0033 e:000032 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/cli.rb:25
c:0006 p:0058 s:0028 e:000027 BLOCK /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/exe/bundle:48
c:0005 p:0007 s:0022 e:000021 METHOD /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/lib/bundler/friendly_errors.rb:120
c:0004 p:0147 s:0017 E:0013f8 TOP /home/circleci/biggerpockets/vendor/bundle/ruby/3.2.0/gems/bundler-2.3.26/exe/bundle:36 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC :load
c:0002 p:0081 s:0008 E:000770 EVAL /home/circleci/.rubygems/bin/bundle:25 [FINISH]
c:0001 p:0000 s:0003 E:001210 DUMMY [FINISH]
-- Ruby level backtrace information ----------------------------------------
/home/circleci/.rubygems/bin/bundle:25:in `
This should be reported to the Ruby team. There's nothing I can do to fix segfaults in Ruby and Brakeman itself doesn't have C extensions or anything.
Any news? We are also having this problem 😬 Thanks
has anyboy reported it? Do we have a minimal reproduction case?
I got a segfault as well when I upgraded to ruby 3.2.1. I did other changes to my project. In my spec/spec_helper.rb
I changed a line from require "spec_db_helpers"
to require_relative "spec_db_helpers"
and now I don't get that error anymore. I don't know. It would be interesting to know why. In my process of researching I found out that dependencies are bundled with brakeman. This surprised me quite a bit so I found the MR https://github.com/presidentbeef/brakeman/pull/845 to see if I could find some clues about why. I guess some users had issues installing because of a conflict in versions, but I think this is the cause of this issue. I think some of the dependencies included are for ruby 2 and we use ruby 3.2.
I polled down the repo to make my MR #1759 add 3.2 to CI. Since I had it pulled down I tried to run with of master gem "brakeman", path: "~/Downloads/brakeman"
and it worked. I tried to checkout the 5.4.0 tag and it also worked. This made me look into the release process of the gem. Here I found brakeman-lib
, an unbundled (like most other gems) brakeman, which is what I want to use. I think I want to use this at least, any reasons I woundn't @presidentbeef?
Also in my case, it seems a bit flaky. After segfaulting 10 or 20 times suddenly is works ¯_(ツ)_/¯
@elalemanyo @karlentwistle @chaadow , can you replace brakeman
with brakeman-lib
in your gemfiles and report?
@presidentbeef maybe we can add some notes in the description to brakeman so people can choose which version they want to use.
I think some of the dependencies included are for ruby 2 and we use ruby 3.2.
I don't think this has anything to do with the bundled dependencies. I can reliably reproduce a segfault with both brakeman
and brakeman-lib
gems. It doesn't ~happen in gem code and it doesn't happen in native code...~ (Edit: looks like both of those statements are wrong, but the point is having gems install with 3.2 doesn't help.) so I think this has to be a Ruby bug.
I think I want to use this at least, any reasons I woundn't @presidentbeef?
Mainly it means mixing Brakeman's dependencies with your app's dependencies. If you don't have conflicts, then there shouldn't be a problem.
I've opened https://bugs.ruby-lang.org/issues/19433
Thanks for all your work. You probably know better then me. I try to do some more research and comment if I find something.
Witht the instructions on issue I am not able to reproduce the seg fault.
I doubled-checked again, made sure gemsets were nice and clean, etc.
I can fairly reliably (6/10 times) get a segfault scanning Redmine with 3.2.0/3.2.1 and brakeman-lib 5.4.0.
I check again today I it fail 4 of 10 times. cleared out all gems and followed the instruction
Our team was able to solve this by setting the RUBY_GC_HEAP_INIT_SLOTS
environment variable before running brakeman. The idea is that since this issue seems to be related to ruby garbage collection, if we increase the GC stack size, then garbage collection will happen less frequently, and we're less likely to encounter this. Obviously an imperfect solution and may not be practical for some projects, but it worked in our use case. We used RUBY_GC_HEAP_INIT_SLOTS=100000 bundle exec brakeman
, but it's probably a good idea to tune that number a bit for your own project.
You can see the following toward the top of everyone's C level backtraces which seems to have something to do with ruby garbage collection.
-- C level backtrace information -------------------------------------------
/usr/local/lib/libruby.so.3.2(rb_print_backtrace+0xd) [0x7f3421b78e2f] /home/circleci/ruby/vm_dump.c:785
/usr/local/lib/libruby.so.3.2(rb_vm_bugreport) /home/circleci/ruby/vm_dump.c:1080
/usr/local/lib/libruby.so.3.2(rb_bug_for_fatal_signal+0xf4) [0x7f3421970654] /home/circleci/ruby/error.c:813
/usr/local/lib/libruby.so.3.2(sigsegv+0x4d) [0x7f3421ac879d] /home/circleci/ruby/signal.c:964
/lib/x86_64-linux-gnu/libc.so.6(0x7f3421569520) [0x7f3421569520]
/usr/local/lib/libruby.so.3.2(RVALUE_MARKED+0x34) [0x7f3421999b35] /home/circleci/ruby/gc.c:1656
/usr/local/lib/libruby.so.3.2(gc_mark_set) /home/circleci/ruby/gc.c:6930
/usr/local/lib/libruby.so.3.2(gc_mark_ptr) /home/circleci/ruby/gc.c:7044
/usr/local/lib/libruby.so.3.2(gen_ivtbl_mark+0x1b) [0x7f3421b3e1c7] /home/circleci/ruby/variable.c:1037
/usr/local/lib/libruby.so.3.2(rb_mark_generic_ivar) /home/circleci/ruby/variable.c:1047
/usr/local/lib/libruby.so.3.2(RB_BUILTIN_TYPE+0x0) [0x7f342199aff7] /home/circleci/ruby/gc.c:7218
/usr/local/lib/libruby.so.3.2(gc_mark_children) /home/circleci/ruby/gc.c:7221
/usr/local/lib/libruby.so.3.2(gc_mark_stacked_objects+0x78) [0x7f342199cd98] /home/circleci/ruby/gc.c:7437
/usr/local/lib/libruby.so.3.2(gc_mark_stacked_objects_all) /home/circleci/ruby/gc.c:7477
/usr/local/lib/libruby.so.3.2(gc_marks_rest) /home/circleci/ruby/gc.c:8675
/usr/local/lib/libruby.so.3.2(gc_marks+0x423) [0x7f342199ddb3] /home/circleci/ruby/gc.c:8716
/usr/local/lib/libruby.so.3.2(gc_start) /home/circleci/ruby/gc.c:9547
https://bugs.ruby-lang.org/issues/19433 has been closed. It should work in Ruby 3.2.2.
@presidentbeef @runephilosof-karnovgroup Ruby 3.2.2
was released yesterday. I can confirm it works.
[EDIT] To fix this, upgrade ruby to 3.2.2
Loading scanner... Processing application in /Users/chaadow/... Processing gems... [Notice] Detected Rails 7 application Processing configuration... [Notice] Escaping HTML by default Parsing files...
/Users/chaadow/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/sexp_processor-4.16.1/lib/sexp.rb:225: [BUG] Segmentation fault at 0x102400018d508180
ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin21]
Stacktrace
``` -- Control frame information ----------------------------------------------- c:0033 p:0041 s:0191 e:000189 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/sexp_processor-4.16.1/lib/se c:0032 p:0033 s:0185 e:000184 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby3 [FINISH] c:0031 p:---- s:0176 e:000175 CFUNC :_racc_do_parse_c c:0030 p:0008 s:0170 e:000169 METHOD (eval):3 c:0029 p:0056 s:0166 e:000165 BLOCK /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_ c:0028 p:0027 s:0163 e:000162 BLOCK /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/3.2.0/timeout.rb:189 c:0027 p:0004 s:0158 e:000157 BLOCK /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/3.2.0/timeout.rb:36 [FINISH] c:0026 p:---- s:0155 e:000154 CFUNC :catch c:0025 p:0036 s:0150 e:000149 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/3.2.0/timeout.rb:36 c:0024 p:0107 s:0144 E:0006a8 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/3.2.0/timeout.rb:198 c:0023 p:0020 s:0133 E:000238 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_ c:0022 p:0022 s:0126 e:000125 BLOCK /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_ [FINISH] c:0021 p:---- s:0120 e:000119 CFUNC :each c:0020 p:0016 s:0116 e:000115 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bundle/ruby/2.7.0/gems/ruby_parser-3.19.1/lib/ruby_ c:0019 p:0042 s:0108 e:000107 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/file_parser.rb:78 c:0018 p:0151 s:0101 e:000100 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/parsers/template_parser.rb:35 c:0017 p:0008 s:0090 e:000089 BLOCK /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/scanner.rb:81 c:0016 p:0018 s:0085 e:000084 BLOCK /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/file_parser.rb:59 [FINISH] c:0015 p:---- s:0078 e:000077 CFUNC :each c:0014 p:0005 s:0074 e:000073 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/file_parser.rb:55 c:0013 p:0062 s:0069 e:000068 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/scanner.rb:80 c:0012 p:0036 s:0063 e:000062 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/scanner.rb:49 c:0011 p:0075 s:0059 e:000058 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman.rb:392 c:0010 p:0052 s:0052 e:000051 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman.rb:86 c:0009 p:0016 s:0047 e:000046 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/commandline.rb:157 c:0008 p:0005 s:0042 e:000041 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/commandline.rb:125 c:0007 p:0020 s:0034 e:000033 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/commandline.rb:166 c:0006 p:0041 s:0028 e:000027 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/commandline.rb:35 c:0005 p:0030 s:0022 e:000021 METHOD /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/lib/brakeman/commandline.rb:20 c:0004 p:0046 s:0016 e:000015 TOP /Users/chedli/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/brakeman-5.4.0/bin/brakeman:10 [FINISH] c:0003 p:---- s:0013 e:000012 CFUNC :load c:0002 p:0078 s:0008 E:000be0 EVAL /Users/chedli/.rbenv/versions/3.2.0/bin/brakeman:25 [FINISH] c:0001 p:0000 s:0003 E:001740 DUMMY [FINISH] -- Ruby level backtrace information ---------------------------------------- /Users/chedli/.rbenv/versions/3.2.0/bin/brakeman:25:in `