Return-Path: X-Original-To: apmail-activemq-users-archive@www.apache.org Delivered-To: apmail-activemq-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1998496B9 for ; Thu, 29 Sep 2011 09:19:04 +0000 (UTC) Received: (qmail 432 invoked by uid 500); 29 Sep 2011 09:19:01 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 391 invoked by uid 500); 29 Sep 2011 09:19:01 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 346 invoked by uid 99); 29 Sep 2011 09:19:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Sep 2011 09:19:01 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of gcjau-user-2@m.gmane.org designates 80.91.229.12 as permitted sender) Received: from [80.91.229.12] (HELO lo.gmane.org) (80.91.229.12) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Sep 2011 09:18:52 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R9ClE-0001k1-5E for users@activemq.apache.org; Thu, 29 Sep 2011 11:18:32 +0200 Received: from mail.techop.co.uk ([212.159.28.86]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Sep 2011 11:18:32 +0200 Received: from nospam.1.friedbadger by mail.techop.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 29 Sep 2011 11:18:32 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: users@activemq.apache.org From: spam trap Subject: Re: ActiveMQCPP::initializeLibrary() usage Date: Thu, 29 Sep 2011 10:08:12 +0100 Lines: 50 Message-ID: References: <1317254141150-3853754.post@n4.nabble.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: mail.techop.co.uk X-Newsreader: Forte Agent 3.3/32.846 User-Agent: Hamster/2.1.0.11 X-Virus-Checked: Checked by ClamAV on apache.org On Wed, 28 Sep 2011 16:55:41 -0700 (PDT), JRR wrote: >Greetings all, > >I have inherited some AMQ CPP client code. Recently we started seeing random >crashes when ActiveMQCPP::initializeLibrary() was being invoked. These >crashes do not always occur. > >I used [gdb] and the information relating to this crash is as follows: > >------------------------------------------------------------ > >------------------------------------------------------------ > >I have started reading through the AMQ CMS CPP documentation, but I don't >see any documentation for the initializeLibrary() method. > >However, I do see in code examples, that this initializeLibrary() method is >being invoked as one of the first operations in main(). > >In the code that I've inheritted, the AMQ client code is abstracted way down >in a helper class and they >invoke the initializeLibrary() every time they are getting read to make a >connection to the broker. > >I have a theory that initializeLibrary() should be invoked once and only >once. Moreover to make matters >worse, its possible for multile instances of one of our client AMQ objects >to execute at the same time, since we are a multi-threaded SMP system. > >I see a comment in our code above the call that simply says: > // initializeLibrary() is thread-safe. >however I haven't seen any documentation to prove or disprove this, nor have >I found any documentation to explain how the initializeLibrary() method >should be used. > >Can anyone point out documentation for this method? It's mentioned in the reference guide: As a general principle only assume that a method is thread safe iff the documentation says so. The default case is always to assume things are not thread safe. Your problem could easily be caused by a race condition so I would delete the comment and make it thread safe. And I would recommend only calling it once. It can't do any harm.