You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Steve Huston (JIRA)" <qp...@incubator.apache.org> on 2009/08/27 18:04:59 UTC

[jira] Created: (QPID-2076) C++ Broker assumes it can delete a pointer passed by message store plugin

C++ Broker assumes it can delete a pointer passed by message store plugin
-------------------------------------------------------------------------

                 Key: QPID-2076
                 URL: https://issues.apache.org/jira/browse/QPID-2076
             Project: Qpid
          Issue Type: Bug
          Components: C++ Broker
    Affects Versions: 0.5
            Reporter: Steve Huston


The 0.5 broker/message-store plugin arrangement has the plugin allocating an object derived from MessageStore and calling qpid::broker::Broker::setStore(MessageStore*) to allow the broker's normal operation to invoke methods through the pointer.

The passed MessageStore pointer is stored in a std::auto_ptr and the Broker destruction deletes the store. This is not valid in all cases. Particularly, on Windows, different DLLs can have different heaps. Memory allocated in one DLL (such as a plugin) can often not be deleted from a different DLL or executable (such as the broker) - it looks like freeing memory which was never allocated.

It also may be desireable in some cases to pass a pointer to qpid::broker::Broker::setStore() that is not dynamically allocated.

I propose changing the store pointer in qpid::broker::Broker from std::auto_ptr to boost::shared_ptr - this will allow the constructing DLL to control if, when, and how the memory is released.

-- 
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] Resolved: (QPID-2076) C++ Broker assumes it can delete a pointer passed by message store plugin

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

Steve Huston resolved QPID-2076.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 0.6

Patches applied to trunk r821066.

> C++ Broker assumes it can delete a pointer passed by message store plugin
> -------------------------------------------------------------------------
>
>                 Key: QPID-2076
>                 URL: https://issues.apache.org/jira/browse/QPID-2076
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.5
>            Reporter: Steve Huston
>            Assignee: Steve Huston
>             Fix For: 0.6
>
>         Attachments: QPID-2076.diff, steve_test_patch.txt
>
>
> The 0.5 broker/message-store plugin arrangement has the plugin allocating an object derived from MessageStore and calling qpid::broker::Broker::setStore(MessageStore*) to allow the broker's normal operation to invoke methods through the pointer.
> The passed MessageStore pointer is stored in a std::auto_ptr and the Broker destruction deletes the store. This is not valid in all cases. Particularly, on Windows, different DLLs can have different heaps. Memory allocated in one DLL (such as a plugin) can often not be deleted from a different DLL or executable (such as the broker) - it looks like freeing memory which was never allocated.
> It also may be desireable in some cases to pass a pointer to qpid::broker::Broker::setStore() that is not dynamically allocated.
> I propose changing the store pointer in qpid::broker::Broker from std::auto_ptr to boost::shared_ptr - this will allow the constructing DLL to control if, when, and how the memory is released.

-- 
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-2076) C++ Broker assumes it can delete a pointer passed by message store plugin

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

Steve Huston updated QPID-2076:
-------------------------------

    Attachment: QPID-2076.diff

Diffs attached to resolve this issue. Since this requires a change to existing message store modules, I have not checked this in. Please review it this week if you maintain a message store plugin. If I don't hear anything more by Friday Sept 25, I'll commit the changes.

The existing use cases can change to this scheme by constructing a boost::shared_ptr with the newly allocated message store pointer and passing it instead of the naked pointer.

FYI, the case where the store should not be deleted ever is effected by:

  class NoopDeleter {
  public:
      NoopDeleter() {}
      void operator()(qpid::broker::MessageStore *p) {}
  };

....

    NoopDeleter d;
    boost::shared_ptr<qpid::broker::MessageStore> sp(this, d);
    broker->setStore(sp);


> C++ Broker assumes it can delete a pointer passed by message store plugin
> -------------------------------------------------------------------------
>
>                 Key: QPID-2076
>                 URL: https://issues.apache.org/jira/browse/QPID-2076
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.5
>            Reporter: Steve Huston
>         Attachments: QPID-2076.diff
>
>
> The 0.5 broker/message-store plugin arrangement has the plugin allocating an object derived from MessageStore and calling qpid::broker::Broker::setStore(MessageStore*) to allow the broker's normal operation to invoke methods through the pointer.
> The passed MessageStore pointer is stored in a std::auto_ptr and the Broker destruction deletes the store. This is not valid in all cases. Particularly, on Windows, different DLLs can have different heaps. Memory allocated in one DLL (such as a plugin) can often not be deleted from a different DLL or executable (such as the broker) - it looks like freeing memory which was never allocated.
> It also may be desireable in some cases to pass a pointer to qpid::broker::Broker::setStore() that is not dynamically allocated.
> I propose changing the store pointer in qpid::broker::Broker from std::auto_ptr to boost::shared_ptr - this will allow the constructing DLL to control if, when, and how the memory is released.

-- 
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-2076) C++ Broker assumes it can delete a pointer passed by message store plugin

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

Steve Huston reassigned QPID-2076:
----------------------------------

    Assignee: Steve Huston

> C++ Broker assumes it can delete a pointer passed by message store plugin
> -------------------------------------------------------------------------
>
>                 Key: QPID-2076
>                 URL: https://issues.apache.org/jira/browse/QPID-2076
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.5
>            Reporter: Steve Huston
>            Assignee: Steve Huston
>         Attachments: QPID-2076.diff
>
>
> The 0.5 broker/message-store plugin arrangement has the plugin allocating an object derived from MessageStore and calling qpid::broker::Broker::setStore(MessageStore*) to allow the broker's normal operation to invoke methods through the pointer.
> The passed MessageStore pointer is stored in a std::auto_ptr and the Broker destruction deletes the store. This is not valid in all cases. Particularly, on Windows, different DLLs can have different heaps. Memory allocated in one DLL (such as a plugin) can often not be deleted from a different DLL or executable (such as the broker) - it looks like freeing memory which was never allocated.
> It also may be desireable in some cases to pass a pointer to qpid::broker::Broker::setStore() that is not dynamically allocated.
> I propose changing the store pointer in qpid::broker::Broker from std::auto_ptr to boost::shared_ptr - this will allow the constructing DLL to control if, when, and how the memory is released.

-- 
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-2076) C++ Broker assumes it can delete a pointer passed by message store plugin

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

Kim van der Riet updated QPID-2076:
-----------------------------------

    Attachment: steve_test_patch.txt

I tested the patch, all seems to work ok. However, the tests also need mods, see attached patch. The AsyncCompletion.cpp patch is a little ugly because the test uses a MessageStore subclass, and must access the methods of this subclass locally. I could not figure a way to cast this directly from a MessageStore smart pointer, so I left it as a raw pointer and reset a smart pointer for initializing the broker only. If you can come up with a better solution, please do.

> C++ Broker assumes it can delete a pointer passed by message store plugin
> -------------------------------------------------------------------------
>
>                 Key: QPID-2076
>                 URL: https://issues.apache.org/jira/browse/QPID-2076
>             Project: Qpid
>          Issue Type: Bug
>          Components: C++ Broker
>    Affects Versions: 0.5
>            Reporter: Steve Huston
>            Assignee: Steve Huston
>         Attachments: QPID-2076.diff, steve_test_patch.txt
>
>
> The 0.5 broker/message-store plugin arrangement has the plugin allocating an object derived from MessageStore and calling qpid::broker::Broker::setStore(MessageStore*) to allow the broker's normal operation to invoke methods through the pointer.
> The passed MessageStore pointer is stored in a std::auto_ptr and the Broker destruction deletes the store. This is not valid in all cases. Particularly, on Windows, different DLLs can have different heaps. Memory allocated in one DLL (such as a plugin) can often not be deleted from a different DLL or executable (such as the broker) - it looks like freeing memory which was never allocated.
> It also may be desireable in some cases to pass a pointer to qpid::broker::Broker::setStore() that is not dynamically allocated.
> I propose changing the store pointer in qpid::broker::Broker from std::auto_ptr to boost::shared_ptr - this will allow the constructing DLL to control if, when, and how the memory is released.

-- 
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