Segmentation fault running profiler
jcantrill opened this issue · comments
Seg fault one trying to terminate profiling via "control C":
bundle exec ruby-prof --mode=memory -f ./tmp/foo -p graph_html ./bin/fluentd -- -c memory.conf --no-supervisor
$ ruby --version
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]
$ bundler --version
Bundler version 2.1.4
$ gem list | grep ruby-pro
ruby-prof (1.4.3)
$ uname -a
Linux decker 5.17.12-100.fc34.x86_64 #1 SMP PREEMPT Mon May 30 17:47:02 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/lib/ruby-prof/thread.rb:5: [BUG] Segmentation fault at 0x0000000000000020
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0014 p:---- s:0072 e:000071 CFUNC :call_tree
c:0013 p:0003 s:0068 e:000067 METHOD /home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/lib/ruby-prof/thread.rb:5
c:0012 p:0076 s:0064 e:000062 BLOCK (erb):181 [FINISH]
c:0011 p:---- s:0059 e:000058 CFUNC :each
c:0010 p:0075 s:0055 E:0025c0 EVAL (erb):177 [FINISH]
c:0009 p:---- s:0046 e:000045 CFUNC :eval
c:0008 p:0052 s:0038 e:000037 METHOD /home/jeff.cantrill/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/erb.rb:905
c:0007 p:0031 s:0033 E:000b20 METHOD /home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/lib/ruby-prof/printers/graph_html_printer.rb:28
c:0006 p:0011 s:0026 e:000025 BLOCK /home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:317 [FINISH]
c:0005 p:---- s:0022 e:000021 CFUNC :open
c:0004 p:0046 s:0016 e:000015 BLOCK /home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:316 [FINISH]
c:0003 p:---- s:0013 e:000012 CFUNC :chdir
c:0002 p:0061 s:0008 e:000007 BLOCK /home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:312 [FINISH]
c:0001 p:0000 s:0003 E:0019a0 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:312:in `block in <top (required)>'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:312:in `chdir'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:316:in `block (2 levels) in <top (required)>'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:316:in `open'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/bin/ruby-prof:317:in `block (3 levels) in <top (required)>'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/lib/ruby-prof/printers/graph_html_printer.rb:28:in `print'
/home/jeff.cantrill/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/erb.rb:905:in `result'
/home/jeff.cantrill/.rvm/rubies/ruby-2.7.6/lib/ruby/2.7.0/erb.rb:905:in `eval'
(erb):177:in `print'
(erb):177:in `each'
(erb):181:in `block in print'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/lib/ruby-prof/thread.rb:5:in `total_time'
/home/jeff.cantrill/.rvm/gems/ruby-2.7.6@fluentd/gems/ruby-prof-1.4.3/lib/ruby-prof/thread.rb:5:in `call_tree'
Hmm, does that always happen? Is it reproducible? Just with profiling memory? Is the source code of the program available?
It does always happen and is reproducible. Our code is here https://github.com/ViaQ/logging-fluentd/tree/main/fluentd
Trying to look at this, but I'm not following what code you are profiling.
The command line you showed is:
bundle exec ruby-prof --mode=memory -f ./tmp/foo -p graph_html ./bin/fluentd -- -c memory.conf --no-supervisor
So you are profiling the script fluentd in the bin directory.
But I don't see that in the repo you sent:
https://github.com/ViaQ/logging-fluentd/tree/main/fluentd
Could you point me in the right direction? Specifically a link to the fluentd ruby script you are running? And I assume the memory.conf file you are using?
The command line you showed is:
bundle exec ruby-prof --mode=memory -f ./tmp/foo -p graph_html ./bin/fluentd -- -c memory.conf --no-supervisor
My apologies, I was actually running this from a fork of the fluentd repo.
memory.conf:
<system>
log_level info
</system>
<source>
@id mydummysource
@type dummy
rate 1
dummy {"message": "{\"key\":\"v\"}"}
</source>
<filter **>
@type stdout
</filter>
<filter **>
@type parser
key_name message
reserve_data true
hash_value_field structured
remove_key_name_field true
<parse>
@type json
json_parser oj
</parse>
</filter>
<match **>
@type stdout
</filter>
Ah, thanks, will take a look.
Sorry for the delay - tracked down the issue. Will cut a new release shortly.