Forum: Ruby on Rails ActionMailer and Ruby SMTP causing a segmentation fault!

Posted by Don (Guest)
on 2012-01-28 00:15
(Received via mailing list)
I just activated Devise' :confirmable option in my User model.  As 
Devise
tries to send out the confirmation-link email I get a segmentation-fault
error in Ruby's SMTP library:

... lib/ruby/1.9.1/net/smtp.rb:583: [BUG] Segmentation fault

My config/environments/development.rb file has the following:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = { :host => 'localhost:3000' 
}

My /config/initializers/setup_mail.rb file:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "mydomain.com",
  :user_name            => "[redacted]",
  :password             => "[redacted]",
  :authentication       => "plain",
  :enable_starttls_auto => true
}
ActionMailer::Base.default_url_options[:host] = "localhost:3000"

The relevant code in smtp.rb   are these two methods:

def ssl_socket(socket, context)
  OpenSSL::SSL::SSLSocket.new socket, context
end

def tlsconnect(s)
  verified = false
  s = ssl_socket(s, @ssl_context)
  logging "TLS connection started"
  s.sync_close = true
  s.connect  # THIS IS LINE 583
  if @ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE
    s.post_connection_check(@address)
  end
  verified = true
  s
ensure
  s.close unless verified
end

I've tried setting :enable_starttls_auto to false.  I don't get a 
segmentation fault, but no mail goes out either.  I can get a session 
going with the gmail smtp host via the command line.  I'm running on the 
latest version of Mac OS.

Never had to debug a segmentation fault before.  Pretty intimidating. 
Any thoughts, ideas, approaches?
Posted by Colin Law (Guest)
on 2012-01-28 09:42
(Received via mailing list)
On 27 January 2012 23:14, Don <don.leatham@gmail.com> wrote:
> I just activated Devise' :confirmable option in my User model. As Devise
> tries to send out the confirmation-link email I get a segmentation-fault
> error in Ruby's SMTP library:
>
> ... lib/ruby/1.9.1/net/smtp.rb:583: [BUG] Segmentation fault

If you are using ruby 1.9.1 then upgrade to 1.9.2 (or 1.9.3 though
maybe it is still a bit new) or go back to 1.8.7
1.9.1 did not play well with Rails

Colin
Posted by Don (Guest)
on 2012-01-28 19:16
(Received via mailing list)
>> tries to send out the confirmation-link email I get a segmentation-fault
>> error in Ruby's SMTP library:
>>
>> ... lib/ruby/1.9.1/net/smtp.rb:583: [BUG] Segmentation fault

> If you are using ruby 1.9.1 then upgrade to 1.9.2 (or 1.9.3 though
> maybe it is still a bit new) or go back to 1.8.7
>1.9.1 did not play well with Rails

OK I'm confused.  The segmentation fault indicates it is happening in 
the
ruby 1.9.1 version of the SMTP library (see quoted text.)  However, when 
I
go to my project and enter the Rails console, I get this:

      irb(main):001:0> RUBY_VERSION

      => "1.9.3"

And when I go the project directory I get this:

      story_project #   ruby --version

      ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

The full path on the segmentation fault is:

      /Users/don/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/smtp.rb:583:
[BUG] Segmentation fault
What is the deal here?  Why is Ruby 1.9.3 running code from 1.9.1?  Is 
this
common?  Did RVM mess this up some how?

Perplexing!??
Posted by Paul (Guest)
on 2012-01-29 18:41
(Received via mailing list)
First, the 1.9.1 is "normal". That's always the folder it uses.

Second, are you having this problem?
http://www.christopherirish.com/2011/09/02/ruby-1-...
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.