You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by spam trap <no...@spamgourmet.com> on 2011/09/21 13:17:25 UTC

ActiveMQ CPP question -- crashing in destructor

I am writing a C++ application using the ActiveMQ CPP API.  I have
based my code on the example in
http://activemq.apache.org/cms/example.html

However I have moved the creation of the Session, Destination and
Consumer objects of the Consumer class to the constructor.  I
understand that some of these objects are not thread safe but, since I
am not using them from different threads simultaneously, then this
should be OK?

The reason is that the ActiveMQConsumer object is crashing during its
destruction.


Re: ActiveMQ CPP question -- crashing in destructor

Posted by Ivan Pechorin <iv...@gmail.com>.
> Just to make sure I am getting things right I do the following in the
> cleanup:
>
>  delete destination;
>  consumer.stop();
>  session.stop();
>  consumer.close();
>  delete consumer;
>  delete session;
>
> Is this the correct order?

Yes, it looks correct.

Re: ActiveMQ CPP question -- crashing in destructor

Posted by spam trap <no...@spamgourmet.com>.
On Thu, 22 Sep 2011 08:02:47 +0700, Ivan Pechorin
<iv...@gmail.com> wrote:

>>>> The reason is that the ActiveMQConsumer object is crashing during its
>>>> destruction.
>>>>
>>>Stack traces and sample code that reproduces the issue are needed before
>>>any help here, this could result from a number of different scenarios.
>>
>> I am in the process of creating a standalone example that exhibits the
>> problem but I was just checking whether this is a common problem
>> because I am making some obvious error.  The crash happens in
>> ActiveMQConsumer::close() BTW;
>
>Yes, it's a known problem presented as a feature rather than a bug.
>Due to strange design, you can't just stop(), close() and delete your
>consumer. You need to stop the corresponding session before closing
>your consumer:
>
>consumer.stop();
>session.stop();
>consumer.close();
>delete consumer;
>session.start();
>
>(see https://issues.apache.org/jira/browse/AMQCPP-361)

Thanks for the post but I don't believe this is the same issue.  The
application now just crashes instead within the session.stop() method.

Just to make sure I am getting things right I do the following in the
cleanup:

 delete destination;
 consumer.stop();
 session.stop();
 consumer.close();
 delete consumer;
 delete session;

Is this the correct order?


Re: ActiveMQ CPP question -- crashing in destructor

Posted by Ivan Pechorin <iv...@gmail.com>.
>>> The reason is that the ActiveMQConsumer object is crashing during its
>>> destruction.
>>>
>>Stack traces and sample code that reproduces the issue are needed before
>>any help here, this could result from a number of different scenarios.
>
> I am in the process of creating a standalone example that exhibits the
> problem but I was just checking whether this is a common problem
> because I am making some obvious error.  The crash happens in
> ActiveMQConsumer::close() BTW;

Yes, it's a known problem presented as a feature rather than a bug.
Due to strange design, you can't just stop(), close() and delete your
consumer. You need to stop the corresponding session before closing
your consumer:

consumer.stop();
session.stop();
consumer.close();
delete consumer;
session.start();

(see https://issues.apache.org/jira/browse/AMQCPP-361)

Re: ActiveMQ CPP question -- crashing in destructor

Posted by spam trap <no...@spamgourmet.com>.
On Wed, 21 Sep 2011 08:23:40 -0400, Timothy Bish
<ta...@gmail.com> wrote:

>On Wed, 2011-09-21 at 12:17 +0100, spam trap wrote:
>> I am writing a C++ application using the ActiveMQ CPP API.  I have
>> based my code on the example in
>> http://activemq.apache.org/cms/example.html
>> 
>> However I have moved the creation of the Session, Destination and
>> Consumer objects of the Consumer class to the constructor.  I
>> understand that some of these objects are not thread safe but, since I
>> am not using them from different threads simultaneously, then this
>> should be OK?
>> 
>> The reason is that the ActiveMQConsumer object is crashing during its
>> destruction.
>> 
>
>Stack traces and sample code that reproduces the issue are needed before
>any help here, this could result from a number of different scenarios.

I am in the process of creating a standalone example that exhibits the
problem but I was just checking whether this is a common problem
because I am making some obvious error.  The crash happens in
ActiveMQConsumer::close() BTW;

>You might be deleting an uninitialized point or trying to destroy the
>object after the library has been uninitialized.  

Definitely not.


Re: ActiveMQ CPP question -- crashing in destructor

Posted by Timothy Bish <ta...@gmail.com>.
On Wed, 2011-09-21 at 12:17 +0100, spam trap wrote:
> I am writing a C++ application using the ActiveMQ CPP API.  I have
> based my code on the example in
> http://activemq.apache.org/cms/example.html
> 
> However I have moved the creation of the Session, Destination and
> Consumer objects of the Consumer class to the constructor.  I
> understand that some of these objects are not thread safe but, since I
> am not using them from different threads simultaneously, then this
> should be OK?
> 
> The reason is that the ActiveMQConsumer object is crashing during its
> destruction.
> 

Stack traces and sample code that reproduces the issue are needed before
any help here, this could result from a number of different scenarios.
You might be deleting an uninitialized point or trying to destroy the
object after the library has been uninitialized.  

Regards

-- 
Tim Bish
------------
FuseSource
Email: tim.bish@fusesource.com
Web: http://fusesource.com
Twitter: tabish121
Blog: http://timbish.blogspot.com/