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

--pid (pid is not listening for messages ... #56

Open
meetme2meat opened this issue Jul 14, 2016 · 11 comments
Open

--pid (pid is not listening for messages ... #56

meetme2meat opened this issue Jul 14, 2016 · 11 comments

Comments

@meetme2meat
Copy link

meetme2meat commented Jul 14, 2016

I'm running a rbtrace on a plain ruby project with celluloid (Ruby version 2.2.2).

Trying to run a rbtrace from Terminal.

rbtrace -p 9831 -e 'Thread.new{GC.start;require "objspace";io=File.open("9831/FIRST.json", "w"); ObjectSpace.dump_all(output: io); io.close}'

Yield the following result
Error: argument --pid (pid is not listening for messages, did you require "rbtrace").

rbtrace is required successfully on the project.

No idea what is wrong over here.

OS : Ubuntu 16.04 LTS
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]

sudo lsof -p 9831 | grep rbtrace
ruby    9831 joshianiket22  mem       REG                8,1   829136  525167 /home/joshianiket22/.rvm/gems/ruby-2.2.2@the_scp/gems/rbtrace-0.4.8/lib/rbtrace.so
@HappySoft
Copy link

HappySoft commented Jul 25, 2016

rbtrace (v0.4.8) doesn't work when trying to debug a Rails (v3.2.16) app started under Unicorn (v4.3.1, ruby 2.1.2p95).
Got the same message:

Error: argument --pid (pid is not listening for messages, did you require "rbtrace").

Tried to attach to both master and child workers.

@allcentury
Copy link

Is this still true? I am able to attach to child workers but the heap dump doesn't seem to line up with this blog post. I don't see generation keys.

@Overbryd
Copy link

Overbryd commented Jun 23, 2020

Same problem, we are running ruby 2.6.4p104 on a x86_64-linux.
I am trying to rbtrace a Resque worker here.

$ lsof -p 108 | grep rbtrace
bundle  108 root  mem       REG   259,2   683376 7865666 /usr/local/bundle/gems/rbtrace-0.4.13/lib/rbtrace.so
$ rbtrace -p 108 --firehose
*** running `sysctl kernel.msgmnb=1048576` for you to prevent losing events (currently: 16384 bytes)
sysctl: setting key "kernel.msgmnb": Read-only file system
Error: argument --pid (pid is not listening for messages, did you `require "rbtrace"`).
Try --help for help.

@Overbryd
Copy link

I could fix my problem, and get rbtrace to conenct to the process.

The problem was, that require "rbtrace" was happening too early, and was only activating rbtrace in the master controlling process.
We are running a process pool of workers here, and needed to trace the workers doing the work.
That is built using Resque, and it has a convenient hook to place the require in:

# in your lib/tasks/resque.rake

# ... snip
# inside your resque:setup task
Resque.after_fork do |_job|
  require "rbtrace"
end

@tmm1 tmm1 pinned this issue Jul 7, 2020
@vs-zhang
Copy link

vs-zhang commented Jul 7, 2020

Is this still true? I am able to attach to child workers but the heap dump doesn't seem to line up with this blog post. I don't see generation keys.

Hi, @allcentury, do u find out the solution? have the same issue, could not find the file and generation key in the heap report. thanks

@allcentury
Copy link

@vs-zhang I didn't unfortunately.

@mdkent
Copy link

mdkent commented Jul 30, 2021

Potentially the same issue as #86?

@Overload119
Copy link

I have the same problem with Sidekiq and even a Rails console.
Therefore, I'm not sure the issue is the same as #86.

I installed your variant like this:
gem 'rbtrace', require: false, git: 'https://github.com/basecamp/rbtrace.git'

 ~/Projects/sendapostcardonline   dec-18 ●  bundle exec rbtrace -p 75627 --interactive
Error: argument --pid (pid is not listening for messages, did you `require "rbtrace"`).
Try --help for help.

I also tried running a simple irb and then run require 'rbtrace' in it.
Still no luck.

CleanShot 2021-12-20 at 11 36 52

@tmm1
Copy link
Owner

tmm1 commented Dec 20, 2021

I don't think connecting to IRB works since it's blocking on stdin.

In your app's Gemfile you would need require: true no?

@Overload119
Copy link

I've tried various places to add the require statement including in the Gemfile, ApplicationController, and the Puma after_worker_boot handler.

Do you have a minimal reproducible ruby app where I can test this?

I thought irb would work since I can run rbtrace commands in another terminal window.

@benoittgt
Copy link

I think it could be closed. Most of the time it is because the pid chosen is the wrong one no?

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

9 participants