Return-Path: X-Original-To: apmail-activemq-dev-archive@www.apache.org Delivered-To: apmail-activemq-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D6974102D4 for ; Thu, 2 Jan 2014 16:50:16 +0000 (UTC) Received: (qmail 63078 invoked by uid 500); 2 Jan 2014 16:49:55 -0000 Delivered-To: apmail-activemq-dev-archive@activemq.apache.org Received: (qmail 63041 invoked by uid 500); 2 Jan 2014 16:49:53 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 63001 invoked by uid 99); 2 Jan 2014 16:49:50 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jan 2014 16:49:50 +0000 Date: Thu, 2 Jan 2014 16:49:50 +0000 (UTC) From: "Arthur Naseef (JIRA)" To: dev@activemq.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AMQCPP-529) Crash in Threads due to small stack size (set to 32768 bytes) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AMQCPP-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13860323#comment-13860323 ] Arthur Naseef commented on AMQCPP-529: -------------------------------------- I see. So, what are you looking for here? A way to change the stack size, or a wholesale increase in the default size? Keep in mind that large numbers of threads with large stack sizes can use up all available address space for the application, causing an out-of-memory condition. Can you use dynamic allocation with auto_ptr or unique_ptr to ensure deletion of the array at the right time? auto_ptr: http://www.cplusplus.com/reference/memory/auto_ptr/ unique_ptr: http://www.cplusplus.com/reference/memory/unique_ptr/ Something like this is what I'm proposing: {noformat} void onMessage (Message *msg) { char[] data; data = new char[16384]; unique_ptr delete_data_on_leaving_scope(data); ... // Do NOT call delete on data. It will be done by the unique_ptr under all code paths. } {noformat} Note I've never personally used unique_ptr, only auto_ptr, so test this. > Crash in Threads due to small stack size (set to 32768 bytes) > ------------------------------------------------------------- > > Key: AMQCPP-529 > URL: https://issues.apache.org/jira/browse/AMQCPP-529 > Project: ActiveMQ C++ Client > Issue Type: Bug > Components: Decaf > Affects Versions: 3.8.1 > Environment: linux50 > Reporter: omri zomet > Assignee: Timothy Bish > Priority: Critical > > Using version 3.8.1 of activemq-cpp (after using version 3.4.5) - we have suffered a crash in code running in amq threads. > Investigation shows that this happens when trying to use a char[] buffer on stack of size > 16384 , probably due to the stack size being of size 32768. > Thread::Thread() constructors call initializeSelf() with stackSize=(-1), which > in turn call createThreadInstance() with negative stackSize value (hence using PLATFORM_DEFAULT_STACK_SIZE). > Relevant code below: > ---------------------- > #define PLATFORM_DEFAULT_STACK_SIZE 0x8000 > ----------------------- > void createThreadInstance(ThreadHandle* thread, long long stackSize, int priority, bool suspended, threadingTask threadMain, void* threadArg) { > if (stackSize <= 0) { > stackSize = PLATFORM_DEFAULT_STACK_SIZE; > } > ... > } > ---------------------- -- This message was sent by Atlassian JIRA (v6.1.5#6160)