You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Teemu Torma (JIRA)" <ji...@apache.org> on 2011/04/14 13:33:05 UTC

[jira] [Created] (AMQCPP-361) Destroying a consumer may cause a crash

Destroying a consumer may cause a crash
---------------------------------------

                 Key: AMQCPP-361
                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: CMS Impl
    Affects Versions: 3.2.5
         Environment: all
            Reporter: Teemu Torma
            Assignee: Timothy Bish


ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.

Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQCPP-361) Destroying a consumer may cause a crash

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQCPP-361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13020624#comment-13020624 ] 

Timothy Bish commented on AMQCPP-361:
-------------------------------------

Added the interfaces to Session and Consumer in trunk, will be in the next major release.  You can cast to ActiveMQSession and ActiveMQConsumer respectively for now.

> Destroying a consumer may cause a crash
> ---------------------------------------
>
>                 Key: AMQCPP-361
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: CMS Impl
>    Affects Versions: 3.2.5
>         Environment: all
>            Reporter: Teemu Torma
>            Assignee: Timothy Bish
>
> ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.
> Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (AMQCPP-361) Destroying a consumer may cause a crash

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AMQCPP-361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Timothy Bish resolved AMQCPP-361.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 3.4.0

This should have been fixed, reopen if its still an issue.

> Destroying a consumer may cause a crash
> ---------------------------------------
>
>                 Key: AMQCPP-361
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: CMS Impl
>    Affects Versions: 3.2.5
>         Environment: all
>            Reporter: Teemu Torma
>            Assignee: Timothy Bish
>             Fix For: 3.4.0
>
>
> ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.
> Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (AMQCPP-361) Destroying a consumer may cause a crash

Posted by "Teemu Torma (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQCPP-361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019830#comment-13019830 ] 

Teemu Torma commented on AMQCPP-361:
------------------------------------

Ok, I will try that.  Start and stop are not part of cms interface though.

> Destroying a consumer may cause a crash
> ---------------------------------------
>
>                 Key: AMQCPP-361
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: CMS Impl
>    Affects Versions: 3.2.5
>         Environment: all
>            Reporter: Teemu Torma
>            Assignee: Timothy Bish
>
> ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.
> Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQCPP-361) Destroying a consumer may cause a crash

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQCPP-361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019810#comment-13019810 ] 

Timothy Bish commented on AMQCPP-361:
-------------------------------------

This is a bit of a usage issue as much as a bug, C++ object lifetime is not like Java or other Garbage collected languages.  Its a best practice to close each of the CMS resources before deleting them.  Locking the dispatch in the session executor would lead to a deadlock in failover cases, so I'd say its preferable to have to take a bit more care when tearing down your objects then have deadlocks.

> Destroying a consumer may cause a crash
> ---------------------------------------
>
>                 Key: AMQCPP-361
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: CMS Impl
>    Affects Versions: 3.2.5
>         Environment: all
>            Reporter: Teemu Torma
>            Assignee: Timothy Bish
>
> ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.
> Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQCPP-361) Destroying a consumer may cause a crash

Posted by "Timothy Bish (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQCPP-361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019820#comment-13019820 ] 

Timothy Bish commented on AMQCPP-361:
-------------------------------------

You can call stop on a session to stop the session's executor from dispatching any messages.  So you could do something like:

{code}
consumer.stop();
session.stop();
consumer.close();
delete consumer;
session.start();
{code}


> Destroying a consumer may cause a crash
> ---------------------------------------
>
>                 Key: AMQCPP-361
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: CMS Impl
>    Affects Versions: 3.2.5
>         Environment: all
>            Reporter: Teemu Torma
>            Assignee: Timothy Bish
>
> ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.
> Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (AMQCPP-361) Destroying a consumer may cause a crash

Posted by "Teemu Torma (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AMQCPP-361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13019816#comment-13019816 ] 

Teemu Torma commented on AMQCPP-361:
------------------------------------

As far as I can see you will need to close the session before destroying any consumers using it.  

In my usage case, we are using one session and creating consumer to retrieve one message from a topic before closing and throwing the consumer away.  Creating a new session for each consumer is just heavier operation and we were trying to avoid that.

> Destroying a consumer may cause a crash
> ---------------------------------------
>
>                 Key: AMQCPP-361
>                 URL: https://issues.apache.org/jira/browse/AMQCPP-361
>             Project: ActiveMQ C++ Client
>          Issue Type: Bug
>          Components: CMS Impl
>    Affects Versions: 3.2.5
>         Environment: all
>            Reporter: Teemu Torma
>            Assignee: Timothy Bish
>
> ActiveMQSessionExecutor::dispatch gets a consumer and calls consumer's dispatch method without holding any locks in between.  This leaves a window when a consumer can be no longer valid on a dispatch call causing a crash.
> Since this is a timing issue it is hard to demonstrate as such.  If one adds let's say one second sleep in ActiveMQSessionExecutor::dispatch before the call to the consumer->dispatch, and destroys a consumer on a destination which has messages incoming will likely crash the application.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira