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

Segfault: net/http client #93

Closed
amedeiros opened this issue Mar 31, 2014 · 20 comments
Closed

Segfault: net/http client #93

amedeiros opened this issue Mar 31, 2014 · 20 comments

Comments

@amedeiros
Copy link

There seems to be an issue in the net/http standard library that is causing a segfault. I am more or less interested if their is a work around for this with the twilio gem thanks.

home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:920: [BUG] Segmentation fault at 0x007f67a4acc980
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0042 p:---- s:0198 e:000197 CFUNC :connect
c:0041 p:0008 s:0195 e:000194 BLOCK /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:920
c:0040 p:0036 s:0193 E:000b70 BLOCK /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/timeout.rb:91 [FINISH]
c:0039 p:---- s:0188 e:000187 CFUNC :call
c:0038 p:0069 s:0184 E:000a78 METHOD /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/timeout.rb:101
c:0037 p:0508 s:0173 E:000d28 METHOD /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:920
c:0036 p:0007 s:0162 e:000161 METHOD /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:863
c:0035 p:0036 s:0159 e:000158 METHOD /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:852
c:0034 p:0017 s:0156 e:000155 METHOD /home/ubuntu/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http.rb:1369
c:0033 p:0031 s:0149 e:000148 METHOD /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/client.rb:216
c:0032 p:0133 s:0142 e:000141 LAMBDA /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/client.rb:168 [FINISH]
c:0031 p:0031 s:0136 e:000135 METHOD /home/ubuntu/.rvm/gems/ruby-2.1.1/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/list_resource.rb:91

@carlosdp
Copy link
Contributor

That's a crash with a core library in Ruby, so I would look to the Ruby mailing lists for help with that. However, I would recommend trying to reinstall Ruby and see if that helps as you are running the 2.1.0 library on 2.1.1.

@neocxi
Copy link

neocxi commented Apr 28, 2014

I'm also experiencing similar issues with the Twilio client

@carlosdp
Copy link
Contributor

Have you tried updating or reinstalling your Ruby interpreter? This isn't something specific to twilio-ruby but rather the ruby core.

@neocxi
Copy link

neocxi commented Apr 30, 2014

We tried ruby2.0 and ruby2.1 on both Mac & ubuntu 12

The problem seems to manifest under a multithreaded environment since we are using twilio-ruby in sidekiq

@amedeiros
Copy link
Author

I as well was having the same issue when using with sidekiq. However, I did reinstall ruby with RVM and have not experienced the issue again.

@key88sf
Copy link

key88sf commented May 1, 2014

Seeing lots of IOError, and Net:: errors due to running this gem with Sidekiq where more than one SMS send is being processed at the same time.

@pinfieldharm
Copy link

@neocxi @key88sf Did either of you resolve this problem? I'm having something similar with Sidekiq and OpenSSL

@neocxi
Copy link

neocxi commented Jun 19, 2014

@pinfieldharm We wrote our own client and this solves the problem

@key88sf
Copy link

key88sf commented Jun 19, 2014

@pinfieldharm We put a global mutex around all calls to the twilio gem :(

@pinfieldharm
Copy link

@neocxi @key88sf Thanks for the info, I guess I'm going to try the mutex approach too. Sigh.

@nateberkopec
Copy link
Contributor

I'm not seeing a segfault but rather an "IOError: closed stream" when processing jobs with Twilio calls and Sidekiq. I unfortunately also think I'll have to throw a global mutex around the twilio gem. It would be awesome if this library could get thread-safety sorted, but I think they may be limited by Net::HTTP. Perhaps if Twilio used something like Faraday and let us configure our own HTTP clients for use with Twilio::REST we could get it sorted.

@sarmiena
Copy link

sarmiena commented Aug 9, 2015

Is this still an issue with new versions of twilio?

@markquezada
Copy link

@sarmiena Yep.

@carlosdp
Copy link
Contributor

carlosdp commented Sep 1, 2015

Hey guys,

This is a bug with the Ruby standard Net:HTTP library related to openssl. The fix was back ported to Ruby 2.1.2, so just make sure you have an updated Ruby installation.

For more info see: https://bugs.ruby-lang.org/issues/9592 and https://bugs.ruby-lang.org/issues/9839 .

If you are still having issues after upgrading, let us know!

@pinfieldharm
Copy link

@carlosdp thanks for pointing those out. As it so happens, I did see those and use the updated version, still had problems and commented directly on https://bugs.ruby-lang.org/issues/9839 (see the last comment). I'm no longer working with that client so I can't donate the core dump I promise in the comment, but AFAIK its still a problem.

@carlosdp
Copy link
Contributor

NOTE: We are working on the ability to specify a custom HTTP client. Hopefully that will be a solution to this rare segfault. I will close this issue when that is released.

@carlosdp carlosdp changed the title Segfault Segfault: net/http client Oct 21, 2015
@viktornonov
Copy link

I needed this to work so I created a monkey patch that will make twilio works with typhoeus, until the new version of the gem is released. It patches only the POST requests.
I using it with Rails, so I created this file which I put in the config/initiliazers directory:

https://gist.github.com/viktornonov/487e0d56ea6ad8873f54

Also I added the typhoeus gem to the Gemfile. Solved the problem for me.

@carlosdp
Copy link
Contributor

If you upgrade to the 5.0.0.rc2 release candidate, it ships with Faraday by default and a bunch of other features. You can use Typhoeus, for example, easily using:

@client.http_client.adapter = :typhoeus

See the upgrade wiki for more details!

@markquezada
Copy link

🎉

@carlosdp
Copy link
Contributor

carlosdp commented Feb 1, 2016

Given 5.x is on the release path now and publicly available, I'm going to close this issue. Thanks for all the help guys!

@carlosdp carlosdp closed this as completed Feb 1, 2016
ajtack pushed a commit to ajtack/twilio-ruby that referenced this issue Apr 28, 2017
Add more next-gen PHP snippets in the REST/ directory
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