You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Sam Hendley (JIRA)" <qp...@incubator.apache.org> on 2010/02/12 22:52:28 UTC

[jira] Created: (QPID-2405) SASL<->Ruby binding can cause seg_faults

SASL<->Ruby binding can cause seg_faults
----------------------------------------

                 Key: QPID-2405
                 URL: https://issues.apache.org/jira/browse/QPID-2405
             Project: Qpid
          Issue Type: Bug
          Components: Ruby Client
    Affects Versions: 0.5
         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
            Reporter: Sam Hendley
             Fix For: 0.5


There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 

This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 

In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).

I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Assigned: (QPID-2405) SASL<->Ruby binding can cause seg_faults

Posted by "Ted Ross (JIRA)" <qp...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/QPID-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ted Ross reassigned QPID-2405:
------------------------------

    Assignee: Ted Ross

> SASL<->Ruby binding can cause seg_faults
> ----------------------------------------
>
>                 Key: QPID-2405
>                 URL: https://issues.apache.org/jira/browse/QPID-2405
>             Project: Qpid
>          Issue Type: Bug
>          Components: Ruby Client
>    Affects Versions: 0.5
>         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
>            Reporter: Sam Hendley
>            Assignee: Ted Ross
>             Fix For: 0.5
>
>         Attachments: sasl.patch
>
>
> There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 
> This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 
> In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).
> I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Commented: (QPID-2405) SASL<->Ruby binding can cause seg_faults

Posted by "Mo Morsi (JIRA)" <qp...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906356#action_12906356 ] 

Mo Morsi commented on QPID-2405:
--------------------------------

Note this would also occur if simply trying to create a Qpid::Connection from irb as by default it invokes ".inspect" on the return value of every line executed and prints the results (this can be turned off but almost never is as it's one of the most used features of irb).

Also including a Qpid::Connection instance in any class makes that class unavailable to call inspect on or for use in irb as once again this issue will propagate up.

> SASL<->Ruby binding can cause seg_faults
> ----------------------------------------
>
>                 Key: QPID-2405
>                 URL: https://issues.apache.org/jira/browse/QPID-2405
>             Project: Qpid
>          Issue Type: Bug
>          Components: Ruby Client
>    Affects Versions: 0.5
>         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
>            Reporter: Sam Hendley
>            Assignee: Ted Ross
>             Fix For: 0.5
>
>         Attachments: sasl.patch
>
>
> There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 
> This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 
> In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).
> I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Commented: (QPID-2405) SASL<->Ruby binding can cause seg_faults

Posted by "Paweł Krześniak (JIRA)" <qp...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908664#action_12908664 ] 

Paweł Krześniak commented on QPID-2405:
---------------------------------------

I can confirm that bug exists. Invoiking inspect method on Connection or Broker ends up with segfault:
---
$ ruby -e 'require "qpid"; s=Qpid::Qmf::Session.new(); b=s.add_broker; puts b.inspect'
-e:1: [BUG] Segmentation fault
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.01

Aborted
---
And I can confirm that Sam's patch fixes the problem.

> SASL<->Ruby binding can cause seg_faults
> ----------------------------------------
>
>                 Key: QPID-2405
>                 URL: https://issues.apache.org/jira/browse/QPID-2405
>             Project: Qpid
>          Issue Type: Bug
>          Components: Ruby Client
>    Affects Versions: 0.5
>         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
>            Reporter: Sam Hendley
>            Assignee: Ted Ross
>             Fix For: 0.5
>
>         Attachments: sasl.patch
>
>
> There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 
> This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 
> In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).
> I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Commented: (QPID-2405) SASL<->Ruby binding can cause seg_faults

Posted by "Mo Morsi (JIRA)" <qp...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906355#action_12906355 ] 

Mo Morsi commented on QPID-2405:
--------------------------------

This issue seems to be propagating up and causing some major breakage in the Ruby QPID binding. Case in point, try to do the following:

require 'qpid'
Qpid::Connection.new(TCPSocket.new('localhost', 5672)).inspect

Which currently results in

[BUG] Segmentation fault
ruby 1.8.6 (2010-02-05) [x86_64-linux]


I am running ruby-qpid via the stock RPM that ships on Fedora13 (ruby-qpid version 0.6)

Qpid::Connection::inspect is segfaulting because

  - Qpid::Delegate::Client  is a member of Qpid::Connection
  - Qpid::Delegate::Client attempts to interface with sasl by executing the following in the constructor (/usr/lib/ruby/site_ruby/1.8/qpid/delegates.rb:189)
         @saslConn = Sasl.client_new(@mechanism, @service, args[:host],@username, @password, @min_ssf, @max_ssf)

Attempting to call the "to_s" method (or even the ".class" method) on @saslConn, as would occur when Qpid::Connection.inspect is invoked, results in a segfault _every time_.

I haven't tried the patch above, please shout out if I can do anymore to help get this resolved.

> SASL<->Ruby binding can cause seg_faults
> ----------------------------------------
>
>                 Key: QPID-2405
>                 URL: https://issues.apache.org/jira/browse/QPID-2405
>             Project: Qpid
>          Issue Type: Bug
>          Components: Ruby Client
>    Affects Versions: 0.5
>         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
>            Reporter: Sam Hendley
>            Assignee: Ted Ross
>             Fix For: 0.5
>
>         Attachments: sasl.patch
>
>
> There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 
> This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 
> In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).
> I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Updated: (QPID-2405) SASL<->Ruby binding can cause seg_faults

Posted by "Sam Hendley (JIRA)" <qp...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/QPID-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sam Hendley updated QPID-2405:
------------------------------

    Attachment: sasl.patch

Low impact fix to prevent seg faults by wrapping the raw value in a ruby object.

> SASL<->Ruby binding can cause seg_faults
> ----------------------------------------
>
>                 Key: QPID-2405
>                 URL: https://issues.apache.org/jira/browse/QPID-2405
>             Project: Qpid
>          Issue Type: Bug
>          Components: Ruby Client
>    Affects Versions: 0.5
>         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
>            Reporter: Sam Hendley
>             Fix For: 0.5
>
>         Attachments: sasl.patch
>
>
> There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 
> This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 
> In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).
> I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


[jira] Commented: (QPID-2405) SASL<->Ruby binding can cause seg_faults

Posted by "Sam Hendley (JIRA)" <qp...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/QPID-2405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12847077#action_12847077 ] 

Sam Hendley commented on QPID-2405:
-----------------------------------



I updated this patch against the trunk 0.6 codebase, my earlier patch had a bug that allowed a different sort of segfault in rare cases.

http://github.com/samhendley/qpid/commit/09b0a17b08c8fd0f01be701c8342297b8aab6c1b

> SASL<->Ruby binding can cause seg_faults
> ----------------------------------------
>
>                 Key: QPID-2405
>                 URL: https://issues.apache.org/jira/browse/QPID-2405
>             Project: Qpid
>          Issue Type: Bug
>          Components: Ruby Client
>    Affects Versions: 0.5
>         Environment: Ubuntu, ruby 1.8.7, qpid 0.5
>            Reporter: Sam Hendley
>            Assignee: Ted Ross
>             Fix For: 0.5
>
>         Attachments: sasl.patch
>
>
> There is an issue with the sasl bindings where it returns a raw ruby VALUE type for the sasl context. This works _UNTIL_ the ruby runtime tries to access that variable which then causes a segfault. 
> This is easy to see if you try to inspect the variable at all (like print it or ask for its class or methods). In my application, for reasons I haven't determined yet, just having this variable on the heap meant that when an exception occurred trying to print the exceptions message caused a seg fault. 
> In any case, passing back raw VALUEs to ruby code is a Bad Idea and goes against the spec. There is a simple macro and fix for this which wraps the returned value in a ruby object. This fixes the issue I was having and means the deleting of the object is done automatically (instead of having a manual free function).
> I have a patch with the simple, low impact fix, really it would be better to the extension so the sasl client is repersented as a real ruby object but that would require atleast some client code changes.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org